lindm Posted September 14, 2007 Share Posted September 14, 2007 I have the date as string in the format YYYY-MM-DD. Having problems finding a way to: 1. Add one day and remove one year (2006-12-31 would become 2006-01-01) 2. Remove -MM-DD (2006-12-31 would become 2006) 3. Only keep for instance 06 of 2006-12-31 Been looking at various date functions (http://se.php.net/manual/en/function.date.php) with no luck as well as str_replace... Link to comment https://forums.phpfreaks.com/topic/69379-solved-date-modification/ Share on other sites More sharing options...
effigy Posted September 14, 2007 Share Posted September 14, 2007 Try strtotime. Link to comment https://forums.phpfreaks.com/topic/69379-solved-date-modification/#findComment-348593 Share on other sites More sharing options...
darkfreaks Posted September 14, 2007 Share Posted September 14, 2007 $date = '01/24/2006'; echo date('Y-m-d', strtotime($date)); Link to comment https://forums.phpfreaks.com/topic/69379-solved-date-modification/#findComment-348595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.