cooldude832 Posted January 2, 2008 Share Posted January 2, 2008 I've got some funky results comming on strtotime function <?php echo "Start date: ".date("m-d-Y", strtotime($data['date_start']))."<br />"; echo "Start date: ".$data['date_start']."<br />"; echo "End date: ".date("m-d-Y", strtotime($data['date_end']))."<br />"; echo "End Date: ".$data['date_end']."<Br />"; ?> $data is the raw input in the form mm-dd-yyyy and this is what it returns Start date: 07-11-2025 (Strtotime value) Start date: 20-02-1988 (Input) End date: 07-20-2025 (strtotime value) End Date: 20-02-1997 (input) Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/ Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2008 Share Posted January 2, 2008 it does seem to come right for me which version of php your using.. just try echo date("m-d-Y",strtotime("20-02-1988")); Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/#findComment-427861 Share on other sites More sharing options...
cooldude832 Posted January 2, 2008 Author Share Posted January 2, 2008 it returns the same incorrect date as the inputted source (07-11-2025) version is 4.4.7 02-20-1988 returns: 01-08-2009 20-02-1988 returns: 07-11-2025 1988-02-20 returns: 02-20-1988 1988-20-02 returns: 08-02-1989 so I think I need to make it yyyy-mm-dd Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/#findComment-427864 Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2008 Share Posted January 2, 2008 is your inputed source mm-dd-yyyy if so why your using the date function with "m-d-Y" it better that u just print the row Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/#findComment-427868 Share on other sites More sharing options...
cooldude832 Posted January 2, 2008 Author Share Posted January 2, 2008 I have to verify its a valid date I'm using m-d-y to read it but its going to date("u") so it needs to be accurate Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/#findComment-427869 Share on other sites More sharing options...
kenrbnsn Posted January 2, 2008 Share Posted January 2, 2008 The strtotime() function doesn't know how to interpret the date when the format is dd-mm-yyyy, so it is getting confused. Your best bet is to convert the input date into something strtotime() understands: <?php $input_date = '20-02-1988'; list ($day,$mon,$yr) = explode('-',$input_date); comp_date = $yr . '-' . $mon . '-' . $day; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/#findComment-427875 Share on other sites More sharing options...
cooldude832 Posted January 2, 2008 Author Share Posted January 2, 2008 I'll just reword it so they input as YYYY-mm-dd and because i just need to verify its equal to or greater than today i should be fine Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/#findComment-427885 Share on other sites More sharing options...
jitesh Posted January 2, 2008 Share Posted January 2, 2008 strtotime does not understand your "date type" given as input. Quote Link to comment https://forums.phpfreaks.com/topic/84057-strtotime-issues/#findComment-427932 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.