Canman2005 Posted March 18, 2007 Share Posted March 18, 2007 Hi all I have a problem, if I use print date("d M Y" ,strtotime('03/16/2007')); then it prints 2007 03 16 which is great. I have a form though, which posts a field called "expiry" with a date in the same format as above (ie: 03/16/2007), but I cant get the above to work with a posted date, for example. I have tried $date = $_POST['expiry']; print date("d M Y" ,strtotime("'".$date."'")); But it always prints 01 Jan 1970 Can anyone help? Thanks in advance Ed Quote Link to comment Share on other sites More sharing options...
Barand Posted March 18, 2007 Share Posted March 18, 2007 $date = $_POST['expiry']; print date("d M Y" ,strtotime($date)); Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 18, 2007 Author Share Posted March 18, 2007 Hi that still produces 01 Jan 1970 thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted March 18, 2007 Share Posted March 18, 2007 Works fine for me ??? Is you form method POST, or GET? Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 18, 2007 Author Share Posted March 18, 2007 post Quote Link to comment Share on other sites More sharing options...
Barand Posted March 18, 2007 Share Posted March 18, 2007 if $_POST['expiry'] really contains '03/16/2007' then you have <?php $date = '03/16/2007'; echo date ('Y m d', strtotime($date)); ?> --> 2007 03 16 Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 18, 2007 Author Share Posted March 18, 2007 thanks, I tried that previously and it worked fine, just seems to be an issue with my code, not sure what it is Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 18, 2007 Share Posted March 18, 2007 thanks, I tried that previously and it worked fine, just seems to be an issue with my code, not sure what it is care to share your code? Quote Link to comment Share on other sites More sharing options...
Barand Posted March 18, 2007 Share Posted March 18, 2007 try <?php echo $_POST['expiry'] . '<br>'; $date = $_POST['expiry']; echo date ('Y m d', strtotime($date)); ?> and see what's in there. If you get 1st jan 1970 it's because it isn't recognising the date format Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted March 18, 2007 Author Share Posted March 18, 2007 I get 18/03/2007 1970 01 01 Quote Link to comment Share on other sites More sharing options...
Barand Posted March 18, 2007 Share Posted March 18, 2007 That's d/m/y format, not m/d/y strtotime doen't recognise that. Quote Link to comment 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.