Results 1 to 6 of 6

Thread: convert timestamp to 12/24hr clock time?

  1. #1
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Question convert timestamp to 12/24hr clock time?

    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!
    Last edited by liamallan; 03-17-2010 at 05:57 PM.

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    PHP Code:
    <?php
    $timestamp 
    1268823208;

    echo 
    date('h.ia'$timestamp);
    ?>
    Gives : 10.53am

  3. The Following User Says Thank You to Schmoopy For This Useful Post:

    liamallan (03-17-2010)

  4. #3
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    thanx mate, after a little tweaking to fit in with login script, this is how it looks
    PHP Code:
    $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!

  5. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    PHP Code:
    $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

  6. The Following User Says Thank You to Schmoopy For This Useful Post:

    liamallan (03-17-2010)

  7. #5
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Thumbs up

    Cheers mate, works flawlessly!! thanks for ur time and knowledge!!

  8. #6
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    No probs, if you need more info on the date function just look here: http://uk.php.net/manual/en/function.date.php

  9. The Following User Says Thank You to Schmoopy For This Useful Post:

    liamallan (03-17-2010)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •