By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,566 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

Time again

P: n/a
I want this to show plus (+) 6 hours:

$ftanggal=date("d M Y - H:i", (date("U")));

How?

/Gerry
Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Gerry wrote:
I want this to show plus (+) 6 hours:

$ftanggal=date("d M Y - H:i", (date("U")));

How?


The second parameter to date() is the timestamp to use, in Unix
timestamp format: the number of seconds since January 1, 1970 GMT.

The time() function gives you the current timestamp; you can easily add
or subtract some number of seconds from that value before passing it to
date().

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #2

P: n/a
Like:

$ftanggal=date("d M Y - H:i", (date("U")+60*60*6));
??

/Gerry

On Fri, 29 Oct 2004 02:07:05 -0700, Brion Vibber <br***@pobox.com>
wrote:
Gerry wrote:
I want this to show plus (+) 6 hours:

$ftanggal=date("d M Y - H:i", (date("U")));

How?


The second parameter to date() is the timestamp to use, in Unix
timestamp format: the number of seconds since January 1, 1970 GMT.

The time() function gives you the current timestamp; you can easily add
or subtract some number of seconds from that value before passing it to
date().

-- brion vibber (brion @ pobox.com)


Jul 17 '05 #3

P: n/a

Gerry wrote:
I want this to show plus (+) 6 hours:

$ftanggal=date("d M Y - H:i", (date("U")));


You can also do it this way:

<?
$ftanggal=date("d M Y - H:i", (date("U")));
echo $ftanggal."<br>\n";
$next = date('d M Y - H:i',strtotime('now'));
echo $next."<br>\n";
$next = date('d M Y - H:i',strtotime('now +6 hours'));
echo $next;
?>

Ken

Jul 17 '05 #4

P: n/a
"Gerry" <gn*@excite.com> wrote in message
news:el********************************@4ax.com...
Like:

$ftanggal=date("d M Y - H:i", (date("U")+60*60*6));
??

/Gerry

On Fri, 29 Oct 2004 02:07:05 -0700, Brion Vibber <br***@pobox.com>
wrote:
Gerry wrote:
I want this to show plus (+) 6 hours:

$ftanggal=date("d M Y - H:i", (date("U")));

How?


The second parameter to date() is the timestamp to use, in Unix
timestamp format: the number of seconds since January 1, 1970 GMT.

The time() function gives you the current timestamp; you can easily add
or subtract some number of seconds from that value before passing it to
date().

-- brion vibber (brion @ pobox.com)


Or more simply: $ftanggal=date("d M Y - H:i", (time() + 60*60*6));
Jul 17 '05 #5

P: n/a
Ken Robinson wrote:
$next = date('d M Y - H:i',strtotime('now'));
echo $next."<br>\n";
$next = date('d M Y - H:i',strtotime('now +6 hours'));


Beware -- strtotime() is broken in PHP 5, and 'now' returns times
relative to the previous midnight instead of the current time.

http://bugs.php.net/bug.php?id=29557

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #6

P: n/a
Thanks for help, it seems to work now

/gerry
Jul 17 '05 #7

P: n/a
kingofkolt wrote:

"Gerry" <gn*@excite.com> wrote in message
news:el********************************@4ax.com...
Like:

$ftanggal=date("d M Y - H:i", (date("U")+60*60*6));
??

/Gerry

On Fri, 29 Oct 2004 02:07:05 -0700, Brion Vibber <br***@pobox.com>
wrote:
Gerry wrote:
> I want this to show plus (+) 6 hours:
>
> $ftanggal=date("d M Y - H:i", (date("U")));
>
> How?

The second parameter to date() is the timestamp to use, in Unix
timestamp format: the number of seconds since January 1, 1970 GMT.

The time() function gives you the current timestamp; you can easily add
or subtract some number of seconds from that value before passing it to
date().

-- brion vibber (brion @ pobox.com)


Or more simply: $ftanggal=date("d M Y - H:i", (time() + 60*60*6));


Or to give your server a little break:
$ftanggal=date('d M Y - H:i', (time() + 21600));

:o)
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.