Yammyguy Posted March 16, 2009 Share Posted March 16, 2009 Hello, I'm looking for a solution to change a date in the past. Say, for example - I have a date displayed as: YYYY/MM/DD - 2008/10/12 What I would like to do is move that date back by one day. I've tried the simple stuff like exploding it, subtracting the array[2] by one, then imploding it. That would be fine, but the problem is if it's the first of a new month - then things get sticky. I've tried the mktime() function by writing something like this: mktime(0,0,0,array[1], (array[2] - 1), array[0]); That returned some pretty funky values - obviously not what I wanted. Does anyone have any suggestions? or is this too specific, and I'm going to have to write a whole function that checks for new month, and determines which month it is and therefore applies the appropriate logic for that month? Thanks very much in advance! ~C. Link to comment https://forums.phpfreaks.com/topic/149653-solved-changing-dates-in-the-past/ Share on other sites More sharing options...
JonnoTheDev Posted March 16, 2009 Share Posted March 16, 2009 $date = "2008/10/12"; $x = strtotime("-1 day", strtotime($date)); print date("Y/m/d", $x); Link to comment https://forums.phpfreaks.com/topic/149653-solved-changing-dates-in-the-past/#findComment-785835 Share on other sites More sharing options...
Yammyguy Posted March 16, 2009 Author Share Posted March 16, 2009 $date = "2008/10/12"; $x = strtotime("-1 day", strtotime($date)); print date("Y/m/d", $x); That's absolutely perfect!!! worked like a charm! Thank you very much! ;D Link to comment https://forums.phpfreaks.com/topic/149653-solved-changing-dates-in-the-past/#findComment-785845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.