Log in

View Full Version : Resolved convert timestamp to 12/24hr clock time?



liamallan
03-17-2010, 11:06 AM
hi, im using a users database for my site which uses a timestamp to tell when a user was last logged in. is there any way i could convert this timestamp into 12/24hr clock time? eg. convert 1268823208 into say 10.30am? thanx in advance!

Schmoopy
03-17-2010, 01:30 PM
<?php
$timestamp = 1268823208;

echo date('h.ia', $timestamp);
?>


Gives : 10.53am

liamallan
03-17-2010, 05:42 PM
thanx mate, after a little tweaking to fit in with login script, this is how it looks

$timestamp = $req_user_info['timestamp'];

echo "<b>Last Active: ".date('h.ia', $timestamp)." </b><br><br>";
is there any way i could display the date they were last active as well? eg DD/MM/YYYY. thanx again!

Schmoopy
03-17-2010, 05:52 PM
$timestamp = $req_user_info['timestamp'];

echo "<b>Last Active: ".date('d/m/Y \a\\t h.ia', $timestamp)." </b><br><br>";


Last Active: 17/03/2010 at 10.53am

liamallan
03-17-2010, 05:57 PM
Cheers mate, works flawlessly!! thanks for ur time and knowledge!!

Schmoopy
03-17-2010, 05:59 PM
No probs, if you need more info on the date function just look here: http://uk.php.net/manual/en/function.date.php