piyush23424 Posted March 18, 2010 Share Posted March 18, 2010 I want to convert "15 Mar 10" to "2010-03-15" format How can i do this? Please help me. Thanx Quote Link to comment https://forums.phpfreaks.com/topic/195702-date-format/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2010 Share Posted March 18, 2010 $date = date('Y-m-d',strtotime("15 Mar 10")); Quote Link to comment https://forums.phpfreaks.com/topic/195702-date-format/#findComment-1028158 Share on other sites More sharing options...
piyush23424 Posted March 18, 2010 Author Share Posted March 18, 2010 Thanks for replying. I am getting this error with your code: $date = date('Y-m-d',strtotime($datefor[0])); Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead in C:\xampp\htdocs\vikramtestingarea\guri\explode\explode1.php on line 21 Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead in C:\xampp\htdocs\vikramtestingarea\guri\explode\explode1.php on line 21 1970-01-01 Quote Link to comment https://forums.phpfreaks.com/topic/195702-date-format/#findComment-1028160 Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2010 Share Posted March 18, 2010 I am getting this error with your code: That's not my code. As soon as you altered it or even just copied it into your file and ran it on your server, it became your responsibility for what it does. A) Did you read the error message and set a default time zone like it states. B) The value in $datefor[0] is not what you think because that code gave a default date of 1970-01-01 that corresponds to a zero value from the strtotime() function, meaning that strtotime() could not operate on what you supplied it. Quote Link to comment https://forums.phpfreaks.com/topic/195702-date-format/#findComment-1028164 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.