SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hello there,

    I have some timestamps that were created a while ago in php using the getdate() function.

    Now I'd like to display these old dates in a table but when I do:

    $date_time = getdate($old_timestamp);

    printf("%d:%d:%d", $date_time["year"], $date_time["month"], $date_time["seconds"]);

    e.t.c....

    it returns the timestamp according to the nuber of seconds since the epoch.

    Does anyone know how to avoid this please, as I'd like to display parts of my old timestamps (i.e. year, month and seconds only) and not the whole timestamp itself?

    I realise that I could cut the string into pieces manually, but is there no easier way to display parts of my old timestamp according to the date when it was created and not the epoch?

    getdate() does it fine for current date but not old dates for some reason???

    Thanks very much if you can assist,

    Best wishes,

    Jason

  2. #2
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    from what I understand, you want to take $old_timestamp and convert it into a year , month, etc....

    and for that, you would use date("appropriate code",$old_timestamp); to get each item (year, month) , etc from the timestamp

    goto http://www.php.net/date for details on the code to use in the date() function

    hope that helps! ...
    cogito, ergo sum


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
  •