ryeman98 Posted September 2, 2008 Share Posted September 2, 2008 Hey there, I have a script where I need the date to be: date("Y-m-d") but have it go back exactly a week. I've tried a few things but I need the Y-m-d format for it to work. Link to comment https://forums.phpfreaks.com/topic/122339-solved-having-the-date-go-back-7-days/ Share on other sites More sharing options...
JasonLewis Posted September 2, 2008 Share Posted September 2, 2008 echo date("Y-m-d", strtotime("-7 Days")); Or you can use mktime(), but the above is easier. Link to comment https://forums.phpfreaks.com/topic/122339-solved-having-the-date-go-back-7-days/#findComment-631706 Share on other sites More sharing options...
ryeman98 Posted September 2, 2008 Author Share Posted September 2, 2008 echo date("Y-m-d", strtotime("-7 Days")); Or you can use mktime(), but the above is easier. Wow, make me look bad Thanks bud! Link to comment https://forums.phpfreaks.com/topic/122339-solved-having-the-date-go-back-7-days/#findComment-631707 Share on other sites More sharing options...
JasonLewis Posted September 2, 2008 Share Posted September 2, 2008 I know. It's too simple, even for PHP. But yeah, you can do many handy things. Like +1 month, etc etc. Link to comment https://forums.phpfreaks.com/topic/122339-solved-having-the-date-go-back-7-days/#findComment-631710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.