473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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($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?
Mar 27 '08 #1
3 1669
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($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
Mar 27 '08 #2
GorseFox wrote:
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/
Mar 27 '08 #3
GorseFox wrote:
$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/
Mar 28 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
16
by: jason | last post by:
I'm tearing out my hair here: ACCESS 2000: When I attempt to overwrite a date in my date field with a new user selected valid date eg: 05/23/99 my date field changes to the TIME I updated the...
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
21
by: Javier | last post by:
Hi I´ve a routine that will read date and times in a vector of strings ie: 30/02/2005 19:20 In some moment I´ll need to check if there are in vector a date like current date with a time...
26
by: sgershon | last post by:
Hi. I know this is should be a simple question. I know server-side web-programming, and never needed to use client-side scripting... until now :) I have done so far a little number of scripts...
3
by: usenet | last post by:
I have inherited a table where date information was saved from PHP as a VARCHAR. (Sigh.) This means that the so-called date fields look like this : August 1, 2005, 9:09 am EDT October 13, 2004,...
3
by: andrew | last post by:
Hi: I am already using TreeMap to massage records in my export file such that each record has a unique key combination ( LastName + FirstName + Member Key) . Thus I am sorting the records by...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
2
by: Billy | last post by:
This string is supposed to provide all records from an MDB database that match the courier and date specified in the query. I Response.Write the query and I get a date as 1/27/2007. The date...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.