blast Posted March 6, 2007 Share Posted March 6, 2007 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 More sharing options...
genericnumber1 Posted March 6, 2007 Share Posted March 6, 2007 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 Link to comment https://forums.phpfreaks.com/topic/41496-solved-strtotime-and-cron/#findComment-201030 Share on other sites More sharing options...
blast Posted March 6, 2007 Author Share Posted March 6, 2007 Is it possible to get time() to just give the time stamp of the date without the current time, cause I need the value to compare with the timestamp of the event in the db. cheers Regards Stu Link to comment https://forums.phpfreaks.com/topic/41496-solved-strtotime-and-cron/#findComment-201120 Share on other sites More sharing options...
blast Posted March 6, 2007 Author Share Posted March 6, 2007 solved. I set the param "12am" to go to strtotime and that seems to have done it. Regards Stu Link to comment https://forums.phpfreaks.com/topic/41496-solved-strtotime-and-cron/#findComment-201143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.