473,320 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

displaying pre-1970 dates

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
9 3199
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
"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
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
"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
>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
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
"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
"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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Craig HB | last post by:
I am using an asp.net table to display postings in a classifieds website. This is a section of the HTM I am using... <asp:table id="tblAdvert" Width="466px" Height="78px" runat="server"...
12
by: Don | last post by:
With the following, I'm trying to display numberOne and numberTwo, each as a two digit character group, such as "nn". If numberOne or numberTwo is less than 10, "bn" will be displayed (where "b"...
4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
2
by: Craig HB | last post by:
I am using an asp.net table to display postings in a classifieds website. This is a section of the HTM I am using... <asp:table id="tblAdvert" Width="466px" Height="78px" runat="server"...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
3
by: raj chahal | last post by:
Hi there I've created a db field with Memo type, and I have stored some text with carriage returns (no html) So the 3 words start on a differnt line. In access this displays correctly ( each...
6
by: Karl Groves | last post by:
I'm trying to work out a mail system which can send an attachment as well as an HTML formatted message (and a default plain text version). I found some pretty good code on PHP.net and modified it...
1
by: ehcy | last post by:
hello guys.. how can i display the <DIR> in my opened files from my text file with table?.. htmlspecialchars is useless.. it always "Warning: file_get_contents() expects parameter 1 to be string,...
14
ddtpmyra
by: ddtpmyra | last post by:
Hi below is my script displaying all the information inside the table. Pupose: pupose of this php page is to display all the information on my table and have a check box at the last column that...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.