Connecting Tech Pros Worldwide Help | Site Map

Date string manipulation

  #1  
Old March 27th, 2008, 10:25 AM
GorseFox
Guest
 
Posts: n/a
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($rssdate) 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?
  #2  
Old March 27th, 2008, 10:35 AM
Luuk
Guest
 
Posts: n/a

re: Date string manipulation


GorseFox schreef:
Quote:
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($rssdate) 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:
http://nl3.php.net/manual/en/function.strtotime.php

and strftime:
http://nl3.php.net/manual/en/function.strftime.php

--
Luuk
  #3  
Old March 27th, 2008, 12:05 PM
Toby A Inkster
Guest
 
Posts: n/a

re: Date string manipulation


GorseFox wrote:
Quote:
Attempts to use strtotime($rssdate) 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!
http://tobyinkster.co.uk/blog/2008/03/23/hypnotist/
  #4  
Old March 28th, 2008, 11:05 AM
Toby A Inkster
Guest
 
Posts: n/a

re: Date string manipulation


GorseFox wrote:
Quote:
$offset = substr($rss_date_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!
http://tobyinkster.co.uk/blog/2008/03/23/hypnotist/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
String manipulation for a date joeferns79 answers 15 August 27th, 2009 02:43 PM
Classic ASP String Manipulation - NOT .net James answers 6 February 16th, 2006 01:25 PM
String manipulation / TEXTAREA input help yerk5@hotmail.com answers 8 July 23rd, 2005 07:24 PM
Convert User entered date and time to Unix Timestamp before inserting to database perplexed answers 13 July 17th, 2005 11:00 AM