Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Get a Date Problem 1

Status
Not open for further replies.

dagger2002

Programmer
Nov 23, 2004
172
US
Hey all hopefully i have a quick fix problem.

I have a database that is holding a date of a message. But I need to format it on the screen, different from how it is being stored in the db.

Being stored as: YYYY-MM-DD

Need MMM(Jan), YYYY

Here is what I have tried:
Code:
date("M, d Y", $row[sto_date])
and
Code:
$msgDate = subStr($row[sto_date], 0, 10);
date("M, d Y", $msgDate)

The Date it is displaying on the screen is Dec 31, 1969.

Any ideas?
 
Just so i i know i understand you you want a date that looks like:

[blue]2007-01-15 [/blue]

to be displayed as

[red]Jan,2007[/red]

correct?

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
can't get a date? use a nicer aftershave?

Code:
echo date('M, Y', strtotime($row['sto_date']));

the date function works with a unix timestamp so you have to convert the yyyy-mm-dd db format to a timestamp either by using a built in mysql function or strtotime (or other php functions).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top