Download the PHP package natilosir/jalali without Composer
On this page you can find all versions of the php package natilosir/jalali. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download natilosir/jalali
More information about natilosir/jalali
Files in natilosir/jalali
Package jalali
Short Description A simple PHP library for managing Jalali (Shamsi) dates.
License MIT
Informations about the package jalali
Jalali Date Converter
This library helps you convert dates between the Gregorian (Miladi) and Jalali (Persian) calendars in PHP. Below are some examples of how to use the library.
Install
Alternatively, you can clone the repository directly:
Use
Example Usage
-
Set the Timezone to Tehran
You can set the timezone to Tehran (UTC+3.5) using theTimezone
method. -
Convert Timestamp to Jalali Date
Convert a Unix timestamp to a Jalali date using thetoj
method. -
Modify the Jalali Date
You can modify a Jalali date by adding hours, days, months, or years using theaddH
,addD
,addM
, andaddY
methods. -
Format the Date in Persian
Use theformat
method to display the date in Persian format. -
Convert Jalali Date to Timestamp
You can convert a Jalali date string to a Unix timestamp using thetot
method. - Convert Jalali Date to Gregorian
Use themiladi
method to convert a Jalali date to its Gregorian counterpart.
Supported Placeholders
Placeholder | Description | Example |
---|---|---|
y |
Last two digits of the Jalali year | 03 |
Y |
Full Jalali year | 1403 |
m |
Numeric representation of the Jalali month | 09 |
M |
Name of the Jalali month (in Persian) | آذر |
d |
Numeric representation of the Jalali day | 25 |
D |
Day suffix (in Persian) | بیستوپنجم |
W |
Day of the week (in Persian) | یکشنبه |
h |
Hour in 12-hour format | 06 |
H |
Hour in 24-hour format | 18 |
i |
Minutes | 33 |
s |
Seconds | 36 |
Example Usage
Placeholders in Action
Given:
- Jalali date:
1403/09/25
- Gregorian timestamp:
2024-12-15 06:33:36
Using the format string 'W D M Y h:i:s'
, the replacements are:
Code Example
Set the timezone to Tehran
Convert timestamp to Jalali date
Modify the Jalali date
Format the date in Persian
Convert Jalali date to timestamp
Convert Jalali date to Gregorian using the miladi method