mrdhood Posted November 23, 2011 Share Posted November 23, 2011 Hey I'm having issues with using strtotime(), date(), and time(). I have a couple problems. The first is: I used strtotime to get the unix of a specific date and time (worked great, even outputted the correct time using date() to return it). However when I went to post information on it (I set it up so that you can't post after the event started), it told me it already started like an hour before it was supposed to. I used if (time() > $event['when']) { echo "too late."; } else { do it } to determine. That had me very confused. Then I decided instead of manually inputting the event times I would pull them from an xml file, which I had no trouble reading. I used: strtotime("Next $day, $time PM") with $day = Sun, $time = 1:00- This outputted a unix timestamp but then date() returned it as being 7 pm on sunday instead. Any ideas what would be causing these strange things? Quote Link to comment https://forums.phpfreaks.com/topic/251700-time-issues/ Share on other sites More sharing options...
mrdhood Posted November 24, 2011 Author Share Posted November 24, 2011 I used if (time() > $event['when']) { echo "too late."; } else { do it } to determine. Wouldn't let me edit, but that was suppose to read ".. to determine whether you can post or not". Quote Link to comment https://forums.phpfreaks.com/topic/251700-time-issues/#findComment-1290849 Share on other sites More sharing options...
teynon Posted November 24, 2011 Share Posted November 24, 2011 What is the value of $event['when'] and time() and what should the values be? Quote Link to comment https://forums.phpfreaks.com/topic/251700-time-issues/#findComment-1290866 Share on other sites More sharing options...
teynon Posted November 24, 2011 Share Posted November 24, 2011 Running this on my machine: echo date("F d, Y G:i:s a", strtotime("Next Sun, 1:00 PM")); Outputs November 27, 2011 13:00:00 pm which is correct. Quote Link to comment https://forums.phpfreaks.com/topic/251700-time-issues/#findComment-1290868 Share on other sites More sharing options...
mrdhood Posted November 24, 2011 Author Share Posted November 24, 2011 I don't have the information from when time() and $event['when'] weren't working. 1322420400 is the int that strtotime("Next Sun, 1:00 PM") returns on my machine, is that the same on yours? Quote Link to comment https://forums.phpfreaks.com/topic/251700-time-issues/#findComment-1290869 Share on other sites More sharing options...
teynon Posted November 24, 2011 Share Posted November 24, 2011 It's important to know where $event['when'] is coming from and what the values are. You need to make a test case or it's going to be hard to figure out whats going on. I promise you strtotime works fine. Quote Link to comment https://forums.phpfreaks.com/topic/251700-time-issues/#findComment-1290887 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.