skip to Main Content

I use Laravel and I deployed my application on Docker
I use carbon package for time management and I set the timezone to Asia/Tehran But now I found a problem and the time are moved forward one hour and I don’t want this one hour to move forward.
Is there a solution for me to move back one hour?

Carbon::now("Asia/Tehran"); //  Asia/Tehran (+04:30)

But i need this

Carbon::now("Asia/Tehran"); //  Asia/Tehran (+03:30)

2

Answers


  1. DateTime (and so Carbon) relies on https://pecl.php.net/package/timezonedb to know which city has which offsets. You need to update it to get the latest info. If it’s not yet available you’ll need to ask the offset explitcly:

    Carbon::now('+03:30')
    
    Login or Signup to reply.
  2. using timezonedb package solve your issue

    pecl install timezonedb
    

    or simply download and install it
    https://pecl.php.net/package/timezonedb/

    after install add this line to php.ini

    extension=timezonedb.so
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search