Jump to content

[SOLVED] strtotime and cron


blast

Recommended Posts

hi there,

basically, I've got a db of events which have dates attached to them which have been created using strtotime().  They don't have any time.. just the date.  I've got a script which gets today's date using strtotime("today").  I use this as a comparison to find events which happen today.  This works fine when I call the script from a URL, however when I called the php file from a cron job... the strtotime("today") creates values which are different each time.

 

Are there any thoughts on what could be causing this?  Firstly, I was wondering if the cron job was somehow using a different timezone to me (I'm On GMT).  How do I explicitly tell php to use GMT.. .but then again.. this should matter too much, because I jsut want to date not the time!  It also wouldn't account for the changing values of strtotime("today").

 

Just out of interest, does php4 and php5 handle strtotime("today") differently?  I'm just wondering if cron is using the correct version of php?

 

 

Thanks in  advance

 

Regards

Stu

Link to comment
https://forums.phpfreaks.com/topic/41496-solved-strtotime-and-cron/
Share on other sites

I'm not sure about cron getting the time wrong, but instead of strtotime('today') you could just use time() -- maybe a simple solution will fix a weird problem?

 

as for changing the timezone -- http://www.php.net/manual/en/function.date-default-timezone-set.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.