musclehead Posted October 2, 2008 Share Posted October 2, 2008 Hi everyone...I'm sure this is a ridiculously-easy question, but I'm killing myself trying to figure it out. I have a date string field, let's say: $theDate = '12-25-2008'; When I echo that variable, it displays beautifully...however, when I try this: echo strtotime($theDate); I get nothing...absolutely nothing is printed on the page...I am completely and utterly stumped...someone cure my insanity/stupidity! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/126809-solved-strtotime-is-giving-me-ulcers/ Share on other sites More sharing options...
DarkWater Posted October 2, 2008 Share Posted October 2, 2008 And you're sure that no number is echo'd? >_> Try adding these lines to the top of the script: ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/126809-solved-strtotime-is-giving-me-ulcers/#findComment-655905 Share on other sites More sharing options...
musclehead Posted October 2, 2008 Author Share Posted October 2, 2008 Positive - I'm not getting any error messages, notices, nothing...it just simple doesn't appear, and I'm totally and completely stumped. Quote Link to comment https://forums.phpfreaks.com/topic/126809-solved-strtotime-is-giving-me-ulcers/#findComment-655910 Share on other sites More sharing options...
discomatt Posted October 2, 2008 Share Posted October 2, 2008 http://www.gnu.org/software/tar/manual/html_node/Calendar-date-items.html#SEC116 Read up <pre><?php var_dump( strtotime('12-25-2008') ); var_dump( strtotime('12/25/2008') ); var_dump( strtotime('2008-12-25') ); ?></pre> bool(false) int(1230192000) int(1230192000) Quote Link to comment https://forums.phpfreaks.com/topic/126809-solved-strtotime-is-giving-me-ulcers/#findComment-655916 Share on other sites More sharing options...
discomatt Posted October 2, 2008 Share Posted October 2, 2008 You want <pre><?php $theDate = '12-25-2008'; var_dump( strtotime( str_replace('-','/',$theDate) ) ); ?></pre> Quote Link to comment https://forums.phpfreaks.com/topic/126809-solved-strtotime-is-giving-me-ulcers/#findComment-655918 Share on other sites More sharing options...
musclehead Posted October 6, 2008 Author Share Posted October 6, 2008 Thanks discomatt - that did the trick! Quote Link to comment https://forums.phpfreaks.com/topic/126809-solved-strtotime-is-giving-me-ulcers/#findComment-658014 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.