Connecting Tech Pros Worldwide Help | Site Map

Time again

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 09:21 AM
Gerry
Guest
 
Posts: n/a
Default Time again

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

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

How?

/Gerry



  #2  
Old July 17th, 2005, 09:21 AM
Brion Vibber
Guest
 
Posts: n/a
Default 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)
  #3  
Old July 17th, 2005, 09:21 AM
Gerry
Guest
 
Posts: n/a
Default 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]

  #4  
Old July 17th, 2005, 09:21 AM
Ken Robinson
Guest
 
Posts: n/a
Default 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

  #5  
Old July 17th, 2005, 09:21 AM
kingofkolt
Guest
 
Posts: n/a
Default 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));


  #6  
Old July 17th, 2005, 09:21 AM
Brion Vibber
Guest
 
Posts: n/a
Default 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)
  #7  
Old July 17th, 2005, 09:22 AM
Gerry
Guest
 
Posts: n/a
Default Re: Time again

Thanks for help, it seems to work now

/gerry
  #8  
Old July 17th, 2005, 09:24 AM
Shawn Wilson
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.