gerkintrigg Posted November 2, 2007 Share Posted November 2, 2007 does the following code give the correct time:? strtotime(date('m/d/Y')) or do I need to use : strtotime(date('d/m/Y')) ? I tried to find out which way the month and day work, but can't seem to find anything that will tell me. I know i did it before but can't put my hands on the code. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/75843-strtotimedatemdy/ Share on other sites More sharing options...
otuatail Posted November 2, 2007 Share Posted November 2, 2007 if you want the current date as a unix time stamp then $val = time(); the date function times a unix time and converts it into a viewable format $val = date("D d-m-yyyy" , 1234561234); What is the end result and from what Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/75843-strtotimedatemdy/#findComment-383862 Share on other sites More sharing options...
Barand Posted November 2, 2007 Share Posted November 2, 2007 strtotime will accept quite a few formats. d/m/y is NOT one of them Easy enough to test which ones work <?php $formats = array( 'm/d/Y', 'd/m/Y', 'm-d-Y', 'd-m-Y', 'd-M-Y', 'd F Y', 'F d Y' ); echo '<table border="1">'; echo '<tr><td>Format</td><td>Today</td><td>strtotime()</td><td>OK?</td></tr>'; foreach ($formats as $f) { $res = date ('d M Y', strtotime (date($f))); $OK = $res == date('d M Y') ? 'OK' : 'X'; echo '<tr><td>', $f, '</td><td>', date($f), '</td><td>', $res, '</td><td>', $OK, '</td></tr>'; } echo '</table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/75843-strtotimedatemdy/#findComment-383934 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.