NLCJ Posted September 22, 2010 Share Posted September 22, 2010 Hello, I've been struggling for days on this problem now. And I'm getting frustrated! I know that the answer is simple, and I've done it before but I cannot figure out what I'm doing wrong. What do I want? Well, I get a date from the database in this format: YYYY-MM-DD. I first want to distract one month from that and then set in into this form: YYYY, MM, DD. I've got this but it's not working (I've tried a lot different values). $transformdate = date("Y-m-d", strtotime("-1 month", $d_datevalue)); $startpoint = str_replace("-", ", ", $transformdate); Thanks, NLCJ Link to comment https://forums.phpfreaks.com/topic/214098-date-minus-1-month/ Share on other sites More sharing options...
adam84 Posted September 22, 2010 Share Posted September 22, 2010 $myDate = explode('-', $row['date'] ); $monthLess = date( "Y-m-d", mktime(0,0,0 ,$myDate[1] - 1 ,$myDate[2],$myDate[0]) ); Something like that Link to comment https://forums.phpfreaks.com/topic/214098-date-minus-1-month/#findComment-1114071 Share on other sites More sharing options...
PFMaBiSmAd Posted September 22, 2010 Share Posted September 22, 2010 $startpoint = date("Y, m, d", strtotime("$d_datevalue -1 month"); Link to comment https://forums.phpfreaks.com/topic/214098-date-minus-1-month/#findComment-1114073 Share on other sites More sharing options...
NLCJ Posted September 22, 2010 Author Share Posted September 22, 2010 Thanks a lot! (Both of you) Link to comment https://forums.phpfreaks.com/topic/214098-date-minus-1-month/#findComment-1114093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.