Jump to content

Dates Before 1970


shadowayex
 Share

Recommended Posts

If this note doesn't apply to you:

The number of the year, may be a two or four digit value, with values between 0-69 mapping to 2000-2069 and 70-100 to 1970-2000. On systems where time_t is a 32bit signed integer, as most common today, the valid range for year is somewhere between 1901 and 2038. However, before PHP 5.1.0 this range was limited from 1970 to 2038 on some systems (e.g. Windows).
i.e., if you need to run this with an older version of PHP or on Windows, then you need to find another way to represent the timestamps.
Link to comment
Share on other sites

It's returning a negative timestamp on the Linux server I'm using. It's possible that other things on the server have something to do with this (e.g. glibc version). It might be best for the sake of portability to find another way to do this.

Link to comment
Share on other sites

The code I'm testig with looks like this:echo mktime(1, 2, 3, 4, 5, 1900);And if it's having these problems I think just making my own version of mktime() may be best as well. Unless someone can figure out why it's not functioning.If I set the year at or after 1970, it works fine. But if it's before 1970, nothing gets printed.

Link to comment
Share on other sites

First, read the note again. A 32-bit signed int will support dates as early as 1901, not 1900. If it's not returning a negative timestamp for dates between 1901 and 1970, or if you need dates before 1901, then you can't use Unix timestamps to represent the date.

Link to comment
Share on other sites

Good call. After some testing the earliest time I can get to work is 8:45:52 PM on December 13th, 1901.I'm using this for a birthdate section on a site I'm working on, so assuming no one over 107 needs to use it, I should be good :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...