By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,077 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,077 IT Pros & Developers. It's quick & easy.

displaying pre-1970 dates

P: n/a
I must be having a brain freeze because I can't figure out how to display
dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06).
I'd like to display as "April 4, 1955".

I've tried using date("F j, Y"), but only get "December 31, 1969".

I'm using PHP 4.3.8. Any suggestions would be appreciated.
Feb 4 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Bosconian wrote:
I must be having a brain freeze because I can't figure out how to
display dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp.
1955-04-06). I'd like to display as "April 4, 1955".

I've tried using date("F j, Y"), but only get "December 31, 1969".

I'm using PHP 4.3.8. Any suggestions would be appreciated.


I'm guessing that you're also using this on a Windows box?

From the PHP manual for the mktime function:
"Before PHP 5.1.0, negative timestamps were not supported under any
known version of Windows and some other systems as well. Therefore the
range of valid years was limited to 1970 through 2038."

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Feb 4 '06 #2

P: n/a
"Kim André Akerĝ" <ki******@NOSPAMbetadome.com> wrote in message
news:44************@individual.net...
Bosconian wrote:
I must be having a brain freeze because I can't figure out how to
display dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp.
1955-04-06). I'd like to display as "April 4, 1955".

I've tried using date("F j, Y"), but only get "December 31, 1969".

I'm using PHP 4.3.8. Any suggestions would be appreciated.


I'm guessing that you're also using this on a Windows box?

From the PHP manual for the mktime function:
"Before PHP 5.1.0, negative timestamps were not supported under any
known version of Windows and some other systems as well. Therefore the
range of valid years was limited to 1970 through 2038."

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)


Actually no, it's Linux (MDK 10.1). Sorry, I should have mentioned that. And
yes, I'm aware of the Windows limitation and have read (and re-read) the
php.net date function docs and user comments (which is usually helpful, but
not in this case.) I even checked google.groups for clues, but no dice.

I can always roll my own output function, but I don't understand why this
isn't working.
Feb 4 '06 #3

P: n/a
Bosconian wrote:
I must be having a brain freeze because I can't figure out how to display
dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06).
I'd like to display as "April 4, 1955".

I've tried using date("F j, Y"), but only get "December 31, 1969".

I'm using PHP 4.3.8. Any suggestions would be appreciated.

This is from somebody that probably don't know what he is talking about.

The manual says that 'date' is used to set the SYSTEM date and time.

That should be why you are being blocked by the epoach wall. Not a
system in the world has a last modified date of 4/4/1955.
Feb 4 '06 #4

P: n/a
"Dave Kelly" <da********@earthlink.net> wrote in message
news:3T******************@newsread2.news.pas.earth link.net...
Bosconian wrote:
I must be having a brain freeze because I can't figure out how to display dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06). I'd like to display as "April 4, 1955".

I've tried using date("F j, Y"), but only get "December 31, 1969".

I'm using PHP 4.3.8. Any suggestions would be appreciated.

This is from somebody that probably don't know what he is talking about.

The manual says that 'date' is used to set the SYSTEM date and time.

That should be why you are being blocked by the epoach wall. Not a
system in the world has a last modified date of 4/4/1955.


Is it possible that you know even less?

Anyone remotely familiar with the date function knows you can pass a second
timestamp argument. I thought my previous message implied this. Shame on me.

From the docs:

string date ( string format [, int timestamp] )

Returns a string formatted according to the given format string using the
given integer timestamp or the current local time if no timestamp is given.
In other words, timestamp is optional and defaults to the value of time().

Linux-based servers support negative timestamps. I tried using strtotime,
but to no avail.
Feb 4 '06 #5

P: n/a
>I must be having a brain freeze because I can't figure out how to display
dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06).
I'd like to display as "April 4, 1955".


I recommend formatting it with MySQL's date_format() function.

e.g.

SELECT date_format(birthdate, "%M %e, %Y") from table where ...;

MySQL's datetime format manages to cover years from 1 to 9999.

Gordon L. Burditt
Feb 4 '06 #6

P: n/a
Bosconian wrote:
I must be having a brain freeze because I can't figure out how to display
dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06).
I'd like to display as "April 4, 1955".

I've tried using date("F j, Y"), but only get "December 31, 1969".

I'm using PHP 4.3.8. Any suggestions would be appreciated.

$months = array('', 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October', 'November', 'December');

Separate year, month and day with strtok or explode and format it yourself.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Feb 4 '06 #7

P: n/a
"Chuck Anderson" <we************@seemy.sig> wrote in message
news:zJ******************************@comcast.com. ..
Bosconian wrote:
I must be having a brain freeze because I can't figure out how to display
dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06).I'd like to display as "April 4, 1955".

I've tried using date("F j, Y"), but only get "December 31, 1969".

I'm using PHP 4.3.8. Any suggestions would be appreciated.

$months = array('', 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October', 'November', 'December');

Separate year, month and day with strtok or explode and format it

yourself.


Yup, that's exactly what I did. I made the months array global because it's
used elsewhere.

// custom output function for displaying pre-1970 dates; expects
"yyyy-mm-dd" date format
// returns full textual month, numeric day (w/o leading zeros) and numeric
4-digit year
function format_date($date) {
global $months;
return $months[intval(substr($date, 5, 2))] . ' ' . intval(substr($date,
8, 2)) . ', ' . substr($date, 0, 4);
}
Feb 5 '06 #8

P: n/a
"Gordon Burditt" <go***********@burditt.org> wrote in message
news:11*************@corp.supernews.com...
I must be having a brain freeze because I can't figure out how to display
dates older than 1970.

I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06).I'd like to display as "April 4, 1955".


I recommend formatting it with MySQL's date_format() function.

e.g.

SELECT date_format(birthdate, "%M %e, %Y") from table where ...;

MySQL's datetime format manages to cover years from 1 to 9999.

Gordon L. Burditt


You're absolutely correct; this can be done in the query and is actually
faster that way.

However, when it's abolutely necessary in PHP the function posted in my
previous message works nicely.
Feb 5 '06 #9

P: n/a

"Bosconian" <bo*******@planetx.com> wrote in message
news:fs******************************@comcast.com. ..
"Dave Kelly" <da********@earthlink.net> wrote in message
news:3T******************@newsread2.news.pas.earth link.net...
Bosconian wrote:
> I must be having a brain freeze because I can't figure out how to display > dates older than 1970.
>
> I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06). > I'd like to display as "April 4, 1955".
>
> I've tried using date("F j, Y"), but only get "December 31, 1969".
>
> I'm using PHP 4.3.8. Any suggestions would be appreciated.
>
> This is from somebody that probably don't know what he is talking about.

The manual says that 'date' is used to set the SYSTEM date and time.

That should be why you are being blocked by the epoach wall. Not a
system in the world has a last modified date of 4/4/1955.


My version 5 manual http://us3.php.net/manual/en/function.date.php doesn't
say that it sets the system time. You must be looking at the unix man pages
for the program "date". PHP manual says it just says it returns a formatted
string.
in the version 5 manual it states this:
Note:
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54
GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond
to the minimum and maximum values for a 32-bit signed integer). However,
before PHP 5.1 this range was limited from 01-01-1970 to 19-01-2038 on some
systems (e.g. Windows).

maybe a PHP upgrade is in order, if possible?

Is it possible that you know even less?

Anyone remotely familiar with the date function knows you can pass a
second
timestamp argument. I thought my previous message implied this. Shame on
me.

From the docs:

string date ( string format [, int timestamp] )

Returns a string formatted according to the given format string using the
given integer timestamp or the current local time if no timestamp is
given.
In other words, timestamp is optional and defaults to the value of time().

Linux-based servers support negative timestamps. I tried using strtotime,
but to no avail.

Feb 8 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.