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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.