SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    Salem, OR
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML date - Elegant PHP manipulation..?

    Hi

    I am querying a web service. It returns an XML doc' with a date field containing a date in this format
    Code:
    2008-08-03T00:00:00.0000000-05:00
    I'm wondering if PHP has a date/time function that can take this data w/out to much manipulation. I could
    Code:
    substr()
    it, chop it up -but I hate to think I'd be missing a more elegant solution.

    Ideally I would want to feed it into
    Code:
    date()
    For later manipulation.

    Any help, greatly appreciated.

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about this?
    PHP Code:
    $date '2008-08-03T00:00:00.0000000-05:00';
    echo 
    date('Y-m-d'strtotime("$date")); 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    How about this?
    PHP Code:
    $date '2008-08-03T00:00:00.0000000-05:00';
    echo 
    date('Y-m-d'strtotime("$date")); 
    maybe a typo, shouldn't it be
    Code PHP:
    strtotime($date)

  4. #4
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    Salem, OR
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exactly what I needed. Thanks so much!


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
  •