samoi Posted September 28, 2009 Share Posted September 28, 2009 Hello guys! How are you? I have records in the database of dates like "yyyy dd mm hh:MM:ss" no dashes in the date format between years days and months! I need to replace the spaces in between the date values to dashes(-) ! so it will look something like this: "yyyy-dd-mm hh:MM:ss" is there any suggestion ? I have used something like this but it has so many errors due to the fact that I am a beginner! for($year=7; $year<10; $year++){ echo "200".$year."-"; } some kind of this algorithm solving ! Link to comment https://forums.phpfreaks.com/topic/175826-dealing-with-editing-a-date-record-how-to-format-it/ Share on other sites More sharing options...
smerny Posted September 28, 2009 Share Posted September 28, 2009 what type of field is your dates column in the db table? not datetime? Link to comment https://forums.phpfreaks.com/topic/175826-dealing-with-editing-a-date-record-how-to-format-it/#findComment-926492 Share on other sites More sharing options...
samoi Posted September 28, 2009 Author Share Posted September 28, 2009 what type of field is your dates column in the db table? not datetime? Unfortunately it was assign as text ! Link to comment https://forums.phpfreaks.com/topic/175826-dealing-with-editing-a-date-record-how-to-format-it/#findComment-926504 Share on other sites More sharing options...
TeNDoLLA Posted September 28, 2009 Share Posted September 28, 2009 If you have to re-format the date in php's side it is easy <?php $date = '2009 28 09 23:59:06'; $date = preg_replace('/\s/', '/', $date, 2); echo $date; Link to comment https://forums.phpfreaks.com/topic/175826-dealing-with-editing-a-date-record-how-to-format-it/#findComment-926600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.