Well, That's the reason I did stop using epoch numbers when manipulating dates. I'd prefer to stick with a date format like ISO$SomeNumberIDontRemember8601 (YYYY-MM-DD HH:MM:SS TZ). This way you won't fall into this type of weirdness, but you won't fall into some common hard-to-track miscalculations like:
- Not everyday has 24 hours, some have 23 and some have 25... so adding 86400 seconds is not really increasing one day...
- Epoch numbers can't care about timezone. When you have your system running on different timezones, you really want to keep the date and time given by the user and save his timeone...(1)
- You'll end using a module that does implement everything you really should care about... please take a look at DateTime...
(1) Well, just to illustrate: Imagine the accounts department of company X in Japan uses the same machine the accounts departament in US. What would happen if you forget about the timezone and convert to epoch numbers?
Well, you will see 2006-01-01 6:00am (Japan TZ), You will convert it to epoch number in that TZ... When people in Japan look the register and will see 2006-01-01 6:00am, but the guys in US will see 2005-12-31 6:00pm (US TZ). Looking by one side, it's correct, because 2006-01-01 6:00am on Japan really was 2005-12-31 6:00pm in US, but that can cause a HUGE confusion...
So, my recommendation is to ALWAYS store the date in a format that allows you to store the TZ, and ALWAYS display the date in the format it was entered, displaying the TZ on which it was entered.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.