pthurmond Posted November 13, 2006 Share Posted November 13, 2006 Will the following code generate a date 30 days in the future?[code]$today = date("Y-n-j");$future = $today + 30;[/code]Thanks,Patrick Link to comment https://forums.phpfreaks.com/topic/27056-dynamic-future-dates/ Share on other sites More sharing options...
Destruction Posted November 13, 2006 Share Posted November 13, 2006 No, but there are functions that will allow you to do this, more notably functions such as mktime I believe which can be used in conjunction with date(). There is an example of date and mktime together in the manual at this page:http://www.php.net/manual/en/function.date.phpHTHDest Link to comment https://forums.phpfreaks.com/topic/27056-dynamic-future-dates/#findComment-123750 Share on other sites More sharing options...
doni49 Posted November 13, 2006 Share Posted November 13, 2006 The following is copied from www.php.net/time:[code]<?php$nextWeek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secsecho 'Now: '. date('Y-m-d') ."\n";echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";?> [/code]So the following should give you 30 days from now:[code]<?php$days = time() + (30 * 24 * 60 * 60); // 30 days; 24 hours; 60 mins; 60secsecho 'Now: '. date('Y-m-d') ."\n";echo '<br>30 Days from now: '. date('Y-m-d', $days) ."\n";?> [/code] Link to comment https://forums.phpfreaks.com/topic/27056-dynamic-future-dates/#findComment-123752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.