RE: [PHP] mktime to determine specific future date
| From: | Ozemail ) | Date: | Tue, 07 Nov 2000 00:18:41 +0000 |
| Subject: | RE: [PHP] mktime to determine specific future date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24018@lists.php.net to get a copy of this message | ||
Hi,
You can use the Unix time to calculate the date. Unix date is based on number of seconds since the
epoch (1 Jan 1970). And there are
24 hrs in a day thus: 24 * 60 * 60 = 86400 seconds in a day. So 90 days would be
86400 * 90 = 7776000 seconds.
Now to find out 90 days from now you simply do
$ninetydays = time() + ( (24 * 60 * 60) * 90 );
> -----Original Message-----
> From: kris@grinz.com [mailto:kris@grinz.com]
> Sent: Tuesday, November 07, 2000 10:08 AM
> To: php-general@lists.php.net
> Subject: [PHP] mktime to determine specific future date
>
>
> I am writing a calendar script and having trouble figuring out how to
> use mktime to determine the date x number of days from current
> date. Currently, the script below outputs the current date. I want it
> to also output "90 days from now is (date 90 days from now)". I'm
> a little confused on how to do this and have read the help page
> already, tried a few things.. no luck. Any ideas out there?
>
> /* GET TODAY */
>
> $year=date(Y, time());
> $month=date(m, time());
> $month_text=mktime(0,0,0,$month,1,$year);
> $month_text=date(F, $month_text);
> $today=date(j, time());
>
> /* insert code to determine date 90 days from current date
> and assign value to $ninetydays */
>
> echo"Today is $month_text $today, $year<p>";
> echo"90 days from now: $ninetydays";
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>