I have to enter user's time in my database and show it to them next time they login as last login time.

You could use JavaScript to populate a hidden field with their localtime when they login.

If you don't want to rely on JS or some other client-side application, you'll need to have the user select his timezone from a form like our Timezone Settings. Then, if you simply store the result of time on login, you can generate the user's last login time in the user's time zone using

my $dt = DateTime->from_epoch( epoch => $epoch_time_stored_in_db, time_zone => $time_zone_stored_in_db, ); print $dt->strftime("Last login at %Y-%m-%d %H:%M:%S\n");

In reply to Re: Time Zone conflict betwen clients in a web application by ikegami
in thread Time Zone conflict betwen clients in a web application by py_201

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.