Results 1 to 4 of 4

Thread: help with date and time stored as int

  1. #1
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default help with date and time stored as int

    Hi,

    im a php/mysql newbie..

    i have a date and time stored as int in sql

    example like this
    1333239000

    how do i display this in my php page
    to be something like

    25/6/2012 7.28am

  2. #2
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    got it

    PHP Code:

    ".date('Y-m-d', $datesub)." 

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    more specifically, to follow your posted format:
    PHP Code:
    <?php
    $datesub 
    1340634480;
    // unix timestamp

    $format 'j/n/Y g.ia';
    // j = day of month (no leading zero - use "d" if you want a leading zero)
    // n = month of year (no leading zero)
    // Y = full year
    // g = hour of day (12-hour format, no leading zero)
    // i = minute of hour
    // a = lowercase am/pm

    print date$format,$datesub );
    // prints "25/6/2012 7.28am"
    Last edited by traq; 04-06-2012 at 03:36 AM.

  4. The Following User Says Thank You to traq For This Useful Post:

    mulaus (04-06-2012)

  5. #4
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Tq Traq

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
  •