mickeymouse Posted December 20, 2019 Share Posted December 20, 2019 I have date 2019-02-01 and I need to subtract x days from it. I believe I first need to convert my date to timestamp, subtract my x days, and convert back to my date format. If that's correct, how do I convert to timestamp? (Just can't find it in documentation.) Tks Link to comment Share on other sites More sharing options...
niche Posted December 20, 2019 Share Posted December 20, 2019 (edited) https://www.w3schools.com/php/php_ref_date.asp https://www.w3schools.com/php/func_date_date_sub.asp https://www.w3schools.com/php/func_date_time.asp EDIT: Let us know if you need any more help Edited December 20, 2019 by niche Link to comment Share on other sites More sharing options...
dsonesuk Posted December 20, 2019 Share Posted December 20, 2019 <?php $adate = '2019-02-01'; $tothisdate = strtotime($adate.' - 2 days'); echo date('Y-m-d ',$tothisdate); ?> Link to comment Share on other sites More sharing options...
dsonesuk Posted December 22, 2019 Share Posted December 22, 2019 Little error, remove space between hyphen '-' and 2. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now