rs_nayr Posted March 20, 2009 Share Posted March 20, 2009 is there a way to convert the value of a variable into a date format? something like this: $dt="2009-2-1" into $dt="2009-02-01"; any ideas guys? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/150319-solved-convert-string-to-date/ Share on other sites More sharing options...
rhodesa Posted March 20, 2009 Share Posted March 20, 2009 <?php $dt = "2009-2-1"; $ts = strtotime($dt); //This makes a unix timestamp $dt = date('Y-m-d',$ts); //Now we can format it to whatever style we want echo $dt; ?> for more formatting options check out: http://www.php.net/date Quote Link to comment https://forums.phpfreaks.com/topic/150319-solved-convert-string-to-date/#findComment-789431 Share on other sites More sharing options...
rs_nayr Posted March 20, 2009 Author Share Posted March 20, 2009 thanks bro,, Quote Link to comment https://forums.phpfreaks.com/topic/150319-solved-convert-string-to-date/#findComment-789510 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.