This library helps PHP users to convert and using Jalali DateTime format

Overview

Easy Jalali for PHP V1.0.0

  • Jalali calendar converter for Persian users in Iran, Afghanistan and other countries that use Jalali calendar.

  • Very thanks of other open-source Jalali libraries: morilog/jalali, jalaali/jalaali-js and jdf

  • In some cases, we may have used some codes or ideas on some of the named libraries.

  • Persian (پارسی) Docs: majid.codes/easy-jalali

How to install:

  • Using Composer

    composer require majidcode/easy-jalali
    

Note: this library has been tested in Laravel 8.x and Laravel 9.x.

How to use:

1. Create your date from original format:

Create a date with one of the fromJalali(), fromGeorgian() or fromCarbon() methods.

Example:

//From Georgian:
$georgianDate = JalaliDate::fromGeorgian('2022-01-12 10:59:59', 'Y-d-m H:i:s');
echo $georgianDate->month();

//From Jalali:
$JalaliDate = JalaliDate::fromJalali('1399-12-12 08:29:59', 'Y-m-d H:i:s');
echo $JalaliDate->month();

//From Carbon:
$carbonDate = JalaliDate::fromCarbon(Carbon::now());
echo $carbonDate->month();

2. Convert to your format:

You can use toGeorgian() or toJalali() functions to convert your date.

Example:

//From Georgian to Jalali:
$georgianDate = JalaliDate::fromGeorgian('2022-01-12 10:59:59', 'Y-d-m H:i:s');
$JalaliDate = $georgianDate->toJalali();

//From Jalali to Georgian:
$JalaliDate = JalaliDate::fromJalali('1399-12-12 08:29:59', 'Y-m-d H:i:s');
$georgianDate = $JalaliDate->toGeorgian();

//From Carbon to Jalali:
$carbonDate = JalaliDate::fromCarbon(Carbon::now());
$JalaliDate = $carbonDate->toJalali();

3. Get your result or format:

You can use document to get different parameters. Format for Georgian date is PHP date formats and Jalali dates is like PHP but has been changed or not supported in some cases.

Example:

//From Georgian to Jalali:
$georgianDate = JalaliDate::fromGeorgian('2022-01-12 10:59:59', 'Y-d-m H:i:s');
$JalaliDate = $georgianDate->toJalali();
echo $JalaliDate->toFormat('ماه F از Y-m-d و h:i:s A');

Example codes:

I have provided some examples in ./example folder that you are easy to use!

Documention:

Supported format characters:

Key For What? Supported in Georgian Supported in Jalali Example returned values
Y A full numeric representation of a year, 4 digits + Yes + Yes Examples: 2021, 1401
y A two digit representation of a year + Yes + Yes Examples: 21 or 01
m Numeric representation of a month, with leading zeros + Yes + Yes 01 through 12
n Numeric representation of a month, without leading zeros + Yes + Yes 1 through 12
F A full textual representation of a month, such as January or March + Yes + Yes January through December - فروردین through اسفند
d Day of the month, 2 digits with leading zeros + Yes + Yes 01 to 31
j Day of the month without leading zeros + Yes + Yes 1 to 31
a Lowercase Ante meridiem and Post meridiem + Yes + Yes am or pm - ق.ظ or ب.ظ
A Uppercase Ante meridiem and Post meridiem + Yes + Yes AM or PM - قبل از ظهر or بعد از ظهر
H 24-hour format of an hour with leading zeros + Yes + Yes 00 through 23
h 12-hour format of an hour with leading zeros + Yes + Yes 01 through 12
G 24-hour format of an hour without leading zeros + Yes + Yes 0 through 23
g 12-hour format of an hour without leading zeros + Yes + Yes 1 through 12
i Minutes with leading zeros + Yes + Yes 00 to 59
s Seconds with leading zeros + Yes + Yes 00 through 59
M A short textual representation of a month, three letters + Yes - No Jan through Dec
D A textual representation of a day, three letters + Yes - No Mon through Sun
l A full textual representation of the day of the week + Yes - No Sunday through Saturday
N ISO 8601 numeric representation of the day of the week + Yes - No 1 (for Monday) through 7 (for Sunday)
S English ordinal suffix for the day of the month, 2 characters + Yes - No st, nd, rd or th. Works well with j
w Numeric representation of the day of the week + Yes - No 0 (for Sunday) through 6 (for Saturday)
z The day of the year (starting from 0) + Yes - No 0 through 365
W ISO 8601 week number of year, weeks starting on Monday + Yes - No Example: 42 (the 42nd week in the year)
t Number of days in the given month + Yes - No 28 through 31
L Whether it's a leap year + Yes - No 1 if it is a leap year, 0 otherwise.
--- Other Official PHP date formats + Yes - No Check PHP Document

Input Functions:

Function Name Inputs
fromJalali() String $JalaliDate: Jalali datetime string, String $format (default: 'Y-m-d H:i:s'): Jalali datetime format
fromGeorgian() String $georgianDate: Georgian datetime string, String $format (default: 'Y-m-d H:i:s'): Georgian datetime format
fromCarbon() Carbon $carbon: Carbon DateTime

Convert Functions:

Function Name For what? Requirement
toJalali() To convert your date to Jalali calender Using after fromGeorgian() or fromCarbon()
toGeorgian() To convert your date to Georgian calender Using after fromJalali()

Output Functions:

Function Name Input Return
toFormat() String $format (default: 'Y-m-d H:i:s'): Datetime format based on your date type String $resultDateByFormat: DateTime based on your $format from input
year() --- $year
month() --- $month
day() --- $day
hour() --- $hour
minute() --- $minute
second() --- $second
You might also like...
CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due

The PHP cron expression parser can parse a CRON expression, determine if it is due to run, calculate the next run date of the expression, and calculate the previous run date of the expression. You can calculate dates far into the future or past by skipping n number of matching dates.

Parse and validate crontab expressions in PHP

Standard (V7) compliant crontab expression parser/validator with support for time zones; see "man 5 crontab" for possible expressions.

Featured Calendar Maker v1.0 multingual extends the functionalities of the latest version of the FullCalendar (5.3.2), the most popular and completed JavaScript Calendar open source
Featured Calendar Maker v1.0 multingual extends the functionalities of the latest version of the FullCalendar (5.3.2), the most popular and completed JavaScript Calendar open source

Featured Calendar Maker v1.0 multingual extends the functionalities of the latest version of the FullCalendar (5.3.2), the most popular and completed JavaScript Calendar open source.

Date Manager PHP Class

Date Manager PHP Class Date Manager Version 1.0.0 PHP class for date management, for example converting solar date to gregorian date and vice versa. C

iCal-creator for PHP - This package offers an abstraction layer for creating iCalendars files

This package offers an abstraction layer for creating iCalendars files. By using this PHP package, you can create *.ics files without the knowledge of the underling format. The output itself will follow RFC 5545 as good as possible.

Add jalali(persian) date to akaunting software

Akaunting Jalali Date Akaunting Jalali Date is a free module developed for Akaunting. It automatically converts all dates to jalali date and change gr

Library to parse, format and convert byte units

Byte Units This is a utility component for parsing, formatting, converting and manipulating byte units in various formats. Usage ?php // Bytes manip

A standalone DateTime library originally based off of Carbon

CakePHP Chronos Chronos aims to be a drop-in replacement for nesbot/carbon. It focuses on providing immutable date/datetime objects. Immutable objects

Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format

Number to Bangla Number, Word or Month Name in Laravel | Get Wordpress Plugin Laravel package to convert English numbers to Bangla number or Bangla te

Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format

Number to Bangla Number, Word or Month Name in Laravel | Get Wordpress Plugin Laravel package to convert English numbers to Bangla number or Bangla te

Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format

Number to Bangla Number, Word or Month Name in Laravel | Get Wordpress Plugin Laravel package to convert English numbers to Bangla number or Bangla te

A PHP component to convert HTML into a plain text format

html2text html2text is a very simple script that uses DOM methods to convert HTML into a format similar to what would be rendered by a browser - perfe

A simple PHP API extension for DateTime.

Carbon An international PHP extension for DateTime. http://carbon.nesbot.com ?php use Carbon\Carbon; printf("Right now is %s", Carbon::now()-toDat

A fluent extension to PHPs DateTime class.

Expressive Date A fluent extension to PHPs DateTime class. Table of Contents Installation Composer Manually Laravel 4 Usage Getting Instances Quick He

Makes working with DateTime fields in Laravel's Nova easier

This package adds a DateTime field with support for a global DateTime format, syntactic sugar for formatting individual DateTime fields and powerful d

The Popular Datetime, Flatpickr Picker as a Filament Form Field
The Popular Datetime, Flatpickr Picker as a Filament Form Field

Flatpickr Date/Time Picker as a Filament Field Flatpickr is one of the most popular js datepickers. This filament plugin allows you to use flatpickr a

A PHP tool that helps you write eBooks in markdown and convert to PDF.
A PHP tool that helps you write eBooks in markdown and convert to PDF.

Artwork by Eric L. Barnes and Caneco from Laravel News ❤️ . This PHP tool helps you write eBooks in markdown. Run ibis build and an eBook will be gene

TweetNow is a Twitter clone created with Vue.js and Laravel. It is a social media platform that allows users to post short messages, follow other users, and engage in conversations through comments and likes.
TweetNow is a Twitter clone created with Vue.js and Laravel. It is a social media platform that allows users to post short messages, follow other users, and engage in conversations through comments and likes.

TweetNow TweetNow is a opensource social media created with Vue.js+Inertia SSR and Laravel. It is a social media platform that allows users to post sh

Releases(1.0.0)
  • 1.0.0(Mar 7, 2022)

    Full Changelog: https://github.com/MajideND/EasyJalali/commits/1.0.0

    Install using composer: composer require majidcode/easy-jalali:1.0.0

    Source code(tar.gz)
    Source code(zip)
A standalone DateTime library originally based off of Carbon

CakePHP Chronos Chronos aims to be a drop-in replacement for nesbot/carbon. It focuses on providing immutable date/datetime objects. Immutable objects

CakePHP 1.3k Jan 1, 2023
A simple PHP API extension for DateTime.

Carbon An international PHP extension for DateTime. http://carbon.nesbot.com <?php use Carbon\Carbon; printf("Right now is %s", Carbon::now()->toDat

Brian Nesbitt 16k Dec 30, 2022
A fluent extension to PHPs DateTime class.

Expressive Date A fluent extension to PHPs DateTime class. Table of Contents Installation Composer Manually Laravel 4 Usage Getting Instances Quick He

Jason Lewis 258 Oct 9, 2021
This helps with public holiday info using google calendar api

Public Holiday This package uses the Google Calendar API to fetch public holidays. The data always comes with 3 years data; the previous year, the cur

Temitope Olotin 5 Jul 13, 2022
Laravel package to convert AD to BS that can work with carbon.

Laravel Nepali Date Converter Laravel package to convert AD to BS that can work with carbon. Installation You can install the package via composer: co

DRH2SO4 19 Jan 5, 2023
Locale-formatted strftime using IntlDateFormatter

This provides a cross-platform alternative to strftime() for when it will be removed from PHP

Fernando Herrero 17 Dec 28, 2022
The easy PHP Library for calculating holidays

Introduction Yasumi (Japanese for 'Holiday'「休み」) is the easy PHP library that helps you retrieve the dates and names of holidays and other special cel

AzuyaLabs 926 Dec 29, 2022
The missing PHP 5.3+ calendar management library.

CalendR CalendR is an Object Oriented Calendar management library on top of PHP5.3+ Date objects. You can use it to deal with all your needs about cal

Yohan Giarelli 462 Dec 30, 2022
A package which provides a monthly calendar with days and events depending on given months and events.

A package which provides a monthly calendar with days and events depending on given months and events. This is where your description should go. Try a

MichaB 6 Nov 1, 2022
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

Support I am a dad now for the last 1,5 years and that clearly shows in being on time with merging PRs or pushing this package further. Time is the bi

Tino Ehrich 944 Dec 21, 2022