rsammy Posted March 12, 2007 Share Posted March 12, 2007 i have a date in this format: 2/5/07 coming in as a string(input). how do i convert it to 02/05/2007? again as a string? thanx Link to comment https://forums.phpfreaks.com/topic/42421-solved-date-conversion/ Share on other sites More sharing options...
anatak Posted March 12, 2007 Share Posted March 12, 2007 look into the function string to date http://www.google.com/search?hl=en&q=php+string+to+date+function&btnG=Google+Search it is amazing what you can find with google isn't it ? http://jp.php.net/manual/en/function.mktime.php will help you maybe http://jp.php.net/manual/en/function.strtotime.php is what you are really looking for so you search should have been string to time or you could write a script that checks the characters on positions in your string 2/5/07 check if second character is a number or / and if it is a / you should put a 0 in front of the first character and check again for the other possible positions of slashes in your string. anatak Link to comment https://forums.phpfreaks.com/topic/42421-solved-date-conversion/#findComment-205793 Share on other sites More sharing options...
rsammy Posted March 13, 2007 Author Share Posted March 13, 2007 thanx for replying. but, i guess its kinda bouncing over my head Link to comment https://forums.phpfreaks.com/topic/42421-solved-date-conversion/#findComment-206476 Share on other sites More sharing options...
obsidian Posted March 13, 2007 Share Posted March 13, 2007 i have a date in this format: 2/5/07 coming in as a string(input). how do i convert it to 02/05/2007? again as a string? strtotime() <?php $date = "2/5/07"; echo date('m/d/Y', strtotime($date)); ?> Link to comment https://forums.phpfreaks.com/topic/42421-solved-date-conversion/#findComment-206481 Share on other sites More sharing options...
rsammy Posted March 13, 2007 Author Share Posted March 13, 2007 i figured it out, thanx! thanx everyone for ur replies! Link to comment https://forums.phpfreaks.com/topic/42421-solved-date-conversion/#findComment-206605 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.