Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can you determine the time on your server rather than using localtime where each user sees a different time?

Title edit by tye

Replies are listed 'Best First'.
Re: Time
by cfreak (Chaplain) on Jun 04, 2003 at 18:32 UTC

    This is sort of a "read the docs" question but I'm feeling nice today :)

    localtime does what you want, it doesn't return a client's local time, in fact it really doesn't even have a way to do that, (assuming this is a web app) you'd need client side scripting such as Javascript to get the client's local time, either that or (web app or not) use some kind of IP to geographic locater and figure out the client's time that way.

    But localtime returns whatever the system's time is set to, if you need Universal time (GMT) then check the gmtime function.

    Lobster Aliens Are attacking the world!
Re: Server time vs. each user's localtime
by Coruscate (Sexton) on Jun 05, 2003 at 06:38 UTC

    Even better, ask the user what timezone they are in and keep that information stored. PerlMonks does this (for registered users), though its implementation is nothing short of awful. Some things use server time, some use the user setting. :(. For you, I'm guessing the best option is asking the user what time it is ;)


    If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.