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 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 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,, 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
Archived
This topic is now archived and is closed to further replies.