SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple Date Formats to Common Format

    I have a bunch of dates in a couple different formats that I would like to convert to a common format. What would be the best way of going about converting them to the common format? The one format in particular is the first one below. Feeding it into date() just returns the 1969 year error.

    Here is an example of some of the dates:
    2006-02-26T17:41:37Z
    Sun, 26 Feb 2006 11:27:00 PST

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    date() expects an integer timestamp, you cant feed it a string

    strtotime() might work,
    but your prob gonna have to use mktime() or gmmktime()

    for that your going to need to parse the string apart first.

    strtotime() could prob handle 2006-02-26T17:41:37Z if you remove the T and the Z, i have no idea what the Z stands for though, maybe the gmt offset.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks clam. I started parsing it out with explode to get the date components and it worked well. THEN, I discovered that strtotime() works on the date with the t and z so problem solved.


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
  •