Link to home
Start Free TrialLog in
Avatar of ceciliamtz
ceciliamtzFlag for Mexico

asked on

Date format for a TIMESTAMP field

Hello

I have a timestamp field on my MySQL DB but I can't get it to show the right way on my pages.

Taking an example from my DB:

TIMESTAMP filed shows: 20040929064953  which is correct

This is the PHP code I am using to format it on my pages:

<?php echo date('d/m/Y',strtotime($row_rsOrden['sol_fecha'])); ?>

but I get

31/12/1969 instead of 29/09/2004

am I missing something?

Thanks

Cecilia
Avatar of cLFlaVA
cLFlaVA


a) Try double-quotes: <?php echo date("d/m/Y",strtotime($row_rsOrden['sol_fecha'])); ?>
b) Echo just the $row_rsOrden['sol_fecha'], see what it gives you
c) What type of server are you running this on?
If its already a timestamp in the database then why are you using strtotime?

<?php echo date('d/m/Y',$row_rsOrden['sol_fecha']); ?>


31/12/1969 will be one second before the unix epoch, you usually get this when dealing with an invalid timestamp or an empty timestamp
ASKER CERTIFIED SOLUTION
Avatar of minichicken
minichicken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ceciliamtz

ASKER

Thanks to all who responded. I got it working with minichicken's suggestion.
Glad you it worked :)
Sorry, grammar turned bad for a second there... :p

I mean, I am gald that it worked for you :)
$isay = $row_Cecilia['understood'];

=)
and many thanks again!