Himani
Himani

Reputation: 265

strtotime() function returning incorrect date

I am getting the date of the next week even when I have set the timezone to UTC-9.

When UTC changes the day i.e 16-03-2017 00:00:00, and the UTC-9 timezone is still 15-03-2017 15:00:00, strtotime() function returns the date of the next week.

$last_time_instance = strtotime(''Wednesday' ' 16:00:00);

The variable $last_time_instance returns the time correctly, but forwards the date to the next week i.e. 22-03-17.

How can I resolve this?

Upvotes: 1

Views: 167

Answers (1)

mickmackusa
mickmackusa

Reputation: 47924

You can append timezone UTC-9 to the string:

$last_time_instance=strtotime('Wednesday 16:00:00 UTC-9');  // 1490803200

$time_instance_formatted=date('d-m-Y H:i:s',$last_time_instance);  // 29-03-2017 12:00:00

Upvotes: 1

Related Questions