Jump to content

showing current date/time problem !!

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
hi everybody

i'm trying to dispaly the current date and time in my websie with one of the following codes:

echo date("l F d, Y, h:i:s"); or echo date("l F d, Y, h:i A");

the problem is with the hour; it displays one hour less than the current hour;

at 10 it displays 9, for example;

any ideas; thanks

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
  • Location:New York, NY
date() uses the time on the server - meaning, the server is probably in a different time zone that you are. If you want to get the clients time, you will either have to use JavaScript or have the user manually set their timezone.

As a side note, it is safe to assume that 99.9% of your users will have the time in either their task bar or finder. Thus displaying the time on your website is kind of redundant.

#3
Paulo_Jorge

Paulo_Jorge

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
thanks,anyway

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
It might be worth noting that many forums and other websites allow registered users to specify their time zone, to allow the server to calculate the difference between its time zone and the users. The result is every display of a date/time is adjusted on the fly.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
kyle1046

kyle1046

    Newbie

  • Members
  • Pip
  • 1 posts
i have the same problem but the server is at 0000 and im at -0500 and i haven't set up a registration page yet




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users