This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > March 2004 > TIMESTAMP REFORMAT IN MYSQL





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author TIMESTAMP REFORMAT IN MYSQL
LithomeNOW

2004-03-19, 1:33 pm

I am using the timestamp function in mysql and then need to format them
so they are legible in my web pages. i.e. change:

20040318115253

into 2004-03-18 or even

03-18-2004
Alan

2004-03-19, 1:33 pm



> I am using the timestamp function in mysql and then need to format them
> so they are legible in my web pages. i.e. change:
>
> 20040318115253
>
> into 2004-03-18 or even
>
> 03-18-2004



timestamp: http://www.phpfreaks.com/mysqlref/6.php

dateformat()
http://www.phpfreaks.com/mysqlref/3.php

http://www.mysql.com/doc/en/Date_an..._functions.html

LithomeNOW

2004-03-21, 1:28 am

After spending hours trying to decifer all the pages on the php, mysql and
Macromedia sites without a simple solution I came up with one. Here it is.

I changed the timestamp column from 14 characters to 8 and would receive:
<?php echo $row_Recordset1['date']; ?></p>
20040322

then simply add ---echo date('m j, Y',strtotime(
to the beginning and add two )) to the end and receive:

<?php echo date('m j, Y',strtotime($row_Recordset1['date'])); ?>
03 21, 2004

Then using the Time formats make some sense, you can add or change as you like:
<?php echo date('F jS, Y',strtotime($row_Recordset1['date'])); ?>
March 21st, 2004

<?php echo date('l, F jS, Y',strtotime($row_Recordset1['date'])); ?>
Sunday, March 21st, 2004

Not too bad.

I wish posters could help with what they have learned rather than give links
to vast amounts a data that must make sense to someone but it would be nice to
remember the old addage "KISS" - Keep it simple stupid

Thanks

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews