Search code examples
phpstrftime

strftime behavior with time at midnight


given is follwing date and time: 25. February 2018 00:00 (ISO 8601 2018-02-25T00:00:00+00:00). A conversation to an UNIX-Timestamp is: 1519516800

Using PHP strftime:

echo strftime("%a %d-%m-%Y", 1519516800); 

gives me

Sat 24-02-2018

where I would expect

Sun 25-02-2018

How can I force an interpretation with the new day? (25th in this case).

thanks!


Solution

  • If you're expecting UTC you need to configure it somewhere:

    date_default_timezone_set('UTC');
    echo strftime("%a %d-%m-%Y", 1519516800);