Any way round the 1970 limitation for Date() on Windows?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Spinball
Forum Newbie
Posts: 6
Joined: Thu Jun 13, 2002 12:23 pm

Any way round the 1970 limitation for Date() on Windows?

Post by Spinball »

Hi,
I have dates stored as strings in a database in the format YYYYMMDD.
I use this so I can sort by date.

I want to display the dates in web pages and use
date("jS F, Y",strtotime($dob))
I need the Date() function to work on dates before 1970.

I've use the rather clumsy

$year = substr($dob,0,4);
if ($year < 1970) {
$dob = substr(date("jS F, Y",strtotime("2000" . substr($dob,4))),0,-4) . $year;
} else {
$dob = date("jS F, Y",strtotime($dob));
}

Is there an easier solution?
Thanks.
Post Reply