Jump to content

[SOLVED] Date and time conversion question


simonp

Recommended Posts

Is there a reason for storing the date in this fashion. Really you should use an INT(10) and use a UNIX timestamp. This value can be converted back to date & time using php's date() function.

 

Timestamp

print time();

You should store it as a DATETIME field.

 

You can do like this though:

<?php
$time = 200908141659;

$unix = mktime(substr($time, 8, 2), substr($time, 10, 2), 0, substr($time, 4, 2), substr($time, 6, 2), substr($time, 0, 4));

echo date('H:i m/d/Y', $unix);

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.