dc_jt Posted March 1, 2007 Share Posted March 1, 2007 Hi Ive got this date function: $due = date('d/m/Y H:i:s'); which obviously displays todays date, how can I get it to display a week todays date?? Thanks Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/ Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 $timeStamp = strtotime($due); $timeStamp += 24 * 60 * 60 * 7; // (add 7 days) $newDate = date("d/m/Y H:i:s", $timeStamp); Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196777 Share on other sites More sharing options...
dc_jt Posted March 1, 2007 Author Share Posted March 1, 2007 $timeStamp = strtotime($due); $timeStamp += 24 * 60 * 60 * 7; // (add 7 days) $newDate = date("d/m/Y H:i:s", $timeStamp); Hi thanks for your help but that seems to ouput: 2007-01-10 11:39:17 When I echo it? Any idea why??? Thanks Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196780 Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 because it was $newDate = date("Y-m-d H:i:s", $timeStamp); earlier I just editted it. to $newDate = date("d/m/Y H:i:s", $timeStamp); I think you used previous one.. have a look at that... Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196783 Share on other sites More sharing options...
dc_jt Posted March 1, 2007 Author Share Posted March 1, 2007 because it was $newDate = date("Y-m-d H:i:s", $timeStamp); earlier I just editted it. to $newDate = date("d/m/Y H:i:s", $timeStamp); I think you used previous one.. have a look at that... Thanks, you were right, however I have to have it in Y-m-d H:i:s format because I have a calendar which works in this format. Is it possible doing it this way? Thanks Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196785 Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 you can change the format to which suits you... by changing date("d/m/Y H:i:s", $timeStamp); the heighlited ... Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196787 Share on other sites More sharing options...
dc_jt Posted March 1, 2007 Author Share Posted March 1, 2007 you can change the format to which suits you... by changing date("d/m/Y H:i:s", $timeStamp); the heighlited ... When I change the format though I get 10/1/2007 Im using this: $due = date('d/m/Y H:i:s'); $timeStamp = strtotime($due); $timeStamp += 24 * 60 * 60 * 7; // (add 7 days) $newDate = date("d/m/Y H:i:s", $timeStamp); echo $newDate; ??? Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196788 Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 Ok... leave the previous one... use this code it works fine $newDate = strtotime("+7 day", time()); $newDate = date("d/m/Y H:i:s", $newDate); Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196792 Share on other sites More sharing options...
dc_jt Posted March 1, 2007 Author Share Posted March 1, 2007 Ok... leave the previous one... use this code it works fine $newDate = strtotime("+7 day", time()); $newDate = date("d/m/Y H:i:s", $newDate); Thank you so much, that works great Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196794 Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 U are always welcome... and please do mark it as SOLVED Link to comment https://forums.phpfreaks.com/topic/40673-date-function-plus-a-week/#findComment-196799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.