Jump to content

[SOLVED] Working with Time and Date - Getting wrong output


MasterACE14

Recommended Posts

I'm trying to echo the date/time from a column in my database, It is echo'ing, but it's not displaying the correct time/date.

 

The column in my database is a timestamp data type.

 

Here is my function I use on the date when I grab it from the database.

<?php
function prettydate($format,$datetime) {

$year = substr( $datetime, 0, 4 );
$mon = substr( $datetime, 4, 2 );
$day = substr( $datetime, 6, 2 );
$hour = substr( $datetime, 8, 2 );
$min = substr( $datetime, 10, 2 );
$sec = substr( $datetime, 12, 2 );
return date($format,mktime( $hour, $min, $sec, $mon, $day, $year ) );

}

 

and I grab the date like so...

<?php
echo prettydate("M j, H:i",$row["date"]);

 

I should be getting something like...

Nov 14, 23:28

at the present time.

 

But I am getting stuff like this...

Nov 1, 14:02

 

any help is greatly appreciated.

 

Regards, ACE

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.