Tuesday, 13 August 2013

PHP date() and strtotime() return wrong months on cron

PHP date() and strtotime() return wrong months on cron

I am using the following to get last month, in different formats, to use
them later on.
<?
date("m", strtotime("first day of -1 month"));
strtolower(date("M", strtotime("first day of -1 month")));
date("F", strtotime("first day of -1 month"));
?>
This is supposed to run on cron and print them out to an external file.
When I run this manually, works as a charm, and it prints out the correct
month (july). However, the cronjob prints out December? (script is running
in August).
Edit: php version is 5.4

No comments:

Post a Comment