Date string manipulation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GorseFox

    Date string manipulation

    Forgive me. I am new to PHP and am a little confused by date
    manipulation and would appreciate some guidance.
    I have a string containing a date which has been parsed from and RSS
    feed. This looks something like: "Tue, 25 Mar 2008 04:28:18 -0500" and
    is stored in $rssdate

    I would like to manipulate this date to correct the timezone
    adjustment. (I happen to know that the item I am referencing was
    actually timestamped at 09:28:18). I suspect that I have to turn it
    into a timestamp (is that correct?)

    Attempts to use strtotime($rssd ate) have failed... and dropping the
    -0500 allows strtotime to complete, but it returns a date of 18 Mar
    (which is counter-intuitive, to say the least).

    Can anyone offer me any clues?
  • Luuk

    #2
    Re: Date string manipulation

    GorseFox schreef:
    Forgive me. I am new to PHP and am a little confused by date
    manipulation and would appreciate some guidance.
    I have a string containing a date which has been parsed from and RSS
    feed. This looks something like: "Tue, 25 Mar 2008 04:28:18 -0500" and
    is stored in $rssdate
    >
    I would like to manipulate this date to correct the timezone
    adjustment. (I happen to know that the item I am referencing was
    actually timestamped at 09:28:18). I suspect that I have to turn it
    into a timestamp (is that correct?)
    >
    Attempts to use strtotime($rssd ate) have failed... and dropping the
    -0500 allows strtotime to complete, but it returns a date of 18 Mar
    (which is counter-intuitive, to say the least).
    >
    Can anyone offer me any clues?
    i think you need strtotime:
    Parse about any English textual datetime description into a Unix timestamp


    and strftime:
    Format a local time/date according to locale settings


    --
    Luuk

    Comment

    • Toby A Inkster

      #3
      Re: Date string manipulation

      GorseFox wrote:
      Attempts to use strtotime($rssd ate) have failed...
      What version of PHP are you using. Parsing the example date you provided
      with strtotime seems to work fine here with PHP 5.2.5.


      --
      Toby A Inkster BSc (Hons) ARCS
      [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
      [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 21:39.]

      Best... News... Story... Ever!

      Comment

      • Toby A Inkster

        #4
        Re: Date string manipulation

        GorseFox wrote:
        $offset = substr($rss_dat e_array[5],1,2); // Grab the hour offset from UTC
        Why ignore the minutes? Yes, there do exist timezones where the minutes
        are not '00'.

        --
        Toby A Inkster BSc (Hons) ARCS
        [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
        [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 20:47.]

        Best... News... Story... Ever!

        Comment

        Working...