» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2006, 08:45 AM
krispy krispy is offline
Junior Member
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
krispy is on a distinguished road
Default date reformatting

I am trying to convert a date that I take from an email. It is in this format:

Wed, 02 Aug 2006 03:59:10 -0700

And I want to convert it to:

2006-08-02

This:
trim(substr($date,12,4))."-".trim(substr($date,8,3))."-".trim(substr($date,5,2))

...will get me:

2006-Aug-02.

Any quick php tips to convert the "Aug" to convert to "08"?

Thanks! -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-13-2006, 08:47 AM
zinedine zinedine is offline
OSP Starters
 
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
zinedine is on a distinguished road
Default

Use this code

$months = array('Jan'=>1,'Feb'=>2,'Mar'=>3,'Apr'=>4,'May'=>' 5', 'Jun'=>6,'Jul'=>7,'Aug'=>8,'Sep'=>9, 'Oct'=>10,'Nov'=>11,'Dec'=>12);$month_no = $months[$month_name];
As for your conversion. You can just try using the strtotime function. Followed by the date() function. Convert the time into unix timestamp using the strtotime function. Then change it into the format of your choice using the date() function.

Good luck -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  #3  
Old 08-13-2006, 08:48 AM
bestguy bestguy is offline
OSP Starters
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
bestguy is on a distinguished road
Default

I have got simper method

Code:
$NewDate = date("Y-m-d", strtotime($OldDate));
Now, I've never used strtotime with the timezone offset like you have there...so I'm not sure how it works. I'll test it when I get a second and see what I come up with.

Edit: Okay, after the 4 second exhaustive test, it appears to work... -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
installation date?? Vrasid MySQL Forums 1 11-23-2006 04:50 AM
retrieving date and time???? Prett MySQL Forums 1 10-28-2006 05:53 AM
MySQL Select Date comparisons functions? features? rice MySQL Forums 1 08-22-2006 02:21 PM
date formatting? Luz MySQL Forums 1 08-09-2006 08:09 AM
best way to calculate date mourinho MySQL Forums 1 06-14-2006 03:17 PM


All times are GMT. The time now is 09:10 AM.