morilog / jalali

This Package helps developers to easily work with Jalali (Shamsi or Iranian) dates in php appliations, based on Jalali (Shamsi) DateTime class.
MIT License
852 stars 107 forks source link

Problem at the current time! #177

Closed salehattari closed 17 hours ago

salehattari commented 1 week ago

Hello. When I use the 'now' method and convert the returned data from the library to a DateTime, the output shows a time that differs from the current time by more than one hour. This could become problematic for larger projects!

morilog commented 3 days ago

Can you provide some examples?

salehattari commented 3 days ago

1 2

If you look carefully at the pictures, you will see that the current time in Iran is 9:18 AM, but the time that the library returns is 7:48 AM! In another image, I have shown you the code that led to this output for a closer look.

morilog commented 23 hours ago

did you set timezone to 'Asia/Tehran'?

salehattari commented 17 hours ago

No! I hadn't done this because I thought the library did this by default.

Important to all friends who have encountered my problem: I was able to fix the problem globally in my project by using the date_default_timezone_set function and setting the time zone to 'Asia/Tehran'.

@morilog Thanks for the tip

The final php code that fixed my problem:

date_default_timezone_set('Asia/Tehran');