ahs10 Posted February 21, 2008 Share Posted February 21, 2008 so from the manual the description is... strtotime — Parse about any English textual datetime description into a Unix timestamp i'm trying to find a more specific way to define "english textual datetime". if just dealing with date shorthand formats (ex - mm/dd/yy), would it be safe to say any format that lists the month before the day? is that accurate? Quote Link to comment https://forums.phpfreaks.com/topic/92327-strtotime-what-constitutes-english-textual-datetime/ Share on other sites More sharing options...
bpops Posted February 21, 2008 Share Posted February 21, 2008 It's actually very impressive what it can do.. pretty much any way you might write the date, it will figure it out. so February 21, 2008 2008-02-21 2/21/08 I'm pretty sure it would get all of them. Best thing to do is to pick one, make sure it works, then use it consistently for your site. Quote Link to comment https://forums.phpfreaks.com/topic/92327-strtotime-what-constitutes-english-textual-datetime/#findComment-473038 Share on other sites More sharing options...
ahs10 Posted February 21, 2008 Author Share Posted February 21, 2008 nope, from previous experience i know proper sql datetime format (yyyy-mm-dd) does not work. that's not a English datetime description (although the one that makes the most sense). that's why i'm trying to grasp the limitations of that term. if i were dealing with dates on my site, i would be consistent, but this is a hard situation to explain. none the yahoo, i'd still like to find the scope of the term "english textual datetime". thanks! Quote Link to comment https://forums.phpfreaks.com/topic/92327-strtotime-what-constitutes-english-textual-datetime/#findComment-473045 Share on other sites More sharing options...
bpops Posted February 21, 2008 Share Posted February 21, 2008 Actually, it does. I use the Mysql format on my site and it works perfectly. If $date has been grabbed from the mysql database (in yyyy-mm-dd format), then $time_s = strtotime($date); $date = date("F j, Y", $time_s); gives me a new string $date that will display 'February 21, 2008' format. Quote Link to comment https://forums.phpfreaks.com/topic/92327-strtotime-what-constitutes-english-textual-datetime/#findComment-473050 Share on other sites More sharing options...
Daniel0 Posted February 21, 2008 Share Posted February 21, 2008 nope, from previous experience i know proper sql datetime format (yyyy-mm-dd) does not work. that's not a English datetime description (although the one that makes the most sense). Although it may not be specifically English it is an ISO standard called ISO 8601. Edit: As specified in the PHP manual can you see all the supported formats here: http://www.gnu.org/software/tar/manual/html_node/tar_113.html Quote Link to comment https://forums.phpfreaks.com/topic/92327-strtotime-what-constitutes-english-textual-datetime/#findComment-473067 Share on other sites More sharing options...
ahs10 Posted February 21, 2008 Author Share Posted February 21, 2008 thanks for that gnu link, that's perfect. so i still hold on to the belief that yyyy-mm-dd does not work with strtotime all the time. i remember a couple of months back posting an issue with that. the solution provided to me was a great tutorial on using DATE_FORMAT and STR_TO_DATE in your db queries. anyweezer, thanks for the discussion and i believe that link was just what i needed. thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/92327-strtotime-what-constitutes-english-textual-datetime/#findComment-473129 Share on other sites More sharing options...
Barand Posted February 21, 2008 Share Posted February 21, 2008 Here's a script to check out various acceptable formats <?php $formats = array( 'Y-m-d', '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/92327-strtotime-what-constitutes-english-textual-datetime/#findComment-473152 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.