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 Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/ 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)); Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210190 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 Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210191 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? Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210192 Share on other sites More sharing options...
Canman2005 Posted March 18, 2007 Author Share Posted March 18, 2007 post Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210195 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 Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210197 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 Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210200 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? Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210201 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 Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210203 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 Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210206 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. Link to comment https://forums.phpfreaks.com/topic/43289-formatting-posted-date/#findComment-210207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.