Solved

# Current time and date + 10 minutes

Posted on 2009-04-22
279 Views
Hi all,

The following contains the current time and date separated in minutes, hour, day, month and year:

\$minutes = date(i);
\$hour = date(G);
\$day = date(j);
\$month = date(n);
\$year = date (Y);

I need exactly the same plus 10 minutes (the current time and date but 10 minutes ahead).
How can I do that?
0

LVL 14

Expert Comment

Hi,

Use this:

\$entry_date = time();

\$display_date = date("m/d/y H:i:s", strtotime(\$entry_date)+strtotime("10 minutes"));
0

Author Comment

Thanks shobinsun, it's what I was looking for .. but how can I get the \$display_date broke down into minute, hour, day, month and year?
Thanks once again!
0

LVL 14

Expert Comment

Hi,

This doing what you want:

date("m/d/y H:i:s", strtotime(\$entry_date)+strtotime("10 minutes"));

or use :

date("M/d/Y H:i:s", strtotime(\$entry_date)+strtotime("10 minutes"));
0

LVL 14

Expert Comment

hi,

use

date("M D Y H:i:s", strtotime(\$entry_date)+strtotime("10 minutes"));
0

Author Comment

Sorry, I don't get it, I'm too new to php :(

What I need is the time and date 10 minutes ahead separated in five variables, one for minutes, one for hour, one for day, one for month and one for year ..

0

LVL 14

Accepted Solution

Hi use this:

\$display_date1 = date("M", strtotime(\$entry_date)+strtotime("10 minutes"));
\$display_date2 = date("D", strtotime(\$entry_date)+strtotime("10 minutes"));
\$display_date3 = date("Y", strtotime(\$entry_date)+strtotime("10 minutes"));
\$display_date4 = date("H", strtotime(\$entry_date)+strtotime("10 minutes"));
\$display_date5 = date("i", strtotime(\$entry_date)+strtotime("10 minutes"));
\$display_date6 = date("s", strtotime(\$entry_date)+strtotime("10 minutes"));
0

Author Closing Comment

thanks!!!
0

## Featured Post

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.