Connecting Tech Pros Worldwide Forums | Help | Site Map

Time again

Gerry
Guest
 
Posts: n/a
#1: Jul 17 '05
I want this to show plus (+) 6 hours:

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

How?

/Gerry



Brion Vibber
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Time again


Gerry wrote:[color=blue]
> I want this to show plus (+) 6 hours:
>
> $ftanggal=date("d M Y - H:i", (date("U")));
>
> How?[/color]

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)
Gerry
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Time again


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 <brion@pobox.com>
wrote:
[color=blue]
>Gerry wrote:[color=green]
>> I want this to show plus (+) 6 hours:
>>
>> $ftanggal=date("d M Y - H:i", (date("U")));
>>
>> How?[/color]
>
>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)[/color]

Ken Robinson
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Time again



Gerry wrote:[color=blue]
> I want this to show plus (+) 6 hours:
>
> $ftanggal=date("d M Y - H:i", (date("U")));
>[/color]

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

kingofkolt
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Time again


"Gerry" <gn_@excite.com> wrote in message
news:el94o0dusa8s22l077pivk52tgnepgkbqb@4ax.com...[color=blue]
> 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 <brion@pobox.com>
> wrote:
>[color=green]
> >Gerry wrote:[color=darkred]
> >> I want this to show plus (+) 6 hours:
> >>
> >> $ftanggal=date("d M Y - H:i", (date("U")));
> >>
> >> How?[/color]
> >
> >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)[/color]
>[/color]

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


Brion Vibber
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Time again


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

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)
Gerry
Guest
 
Posts: n/a
#7: Jul 17 '05

re: Time again


Thanks for help, it seems to work now

/gerry
Shawn Wilson
Guest
 
Posts: n/a
#8: Jul 17 '05

re: Time again


kingofkolt wrote:[color=blue]
>
> "Gerry" <gn_@excite.com> wrote in message
> news:el94o0dusa8s22l077pivk52tgnepgkbqb@4ax.com...[color=green]
> > 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 <brion@pobox.com>
> > wrote:
> >[color=darkred]
> > >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)[/color]
> >[/color]
>
> Or more simply: $ftanggal=date("d M Y - H:i", (time() + 60*60*6));[/color]

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

:o)
Shawn
--
Shawn Wilson
shawn@glassgiant.com
http://www.glassgiant.com
Closed Thread