Page 1 of 1
Solved Converting rrs-date format to MySQL date format
Posted: Sat Sep 12, 2009 9:53 pm
by Peter_w
Hi,
Does anyone has fast way to convert the rrs-date format to MySQL date format?
Thanks,
Re: Converting rrs-date format to MySQL date format
Posted: Sat Sep 12, 2009 11:05 pm
by chris
strtotime is great function in php
Code: Select all
$mysql_date=date(Y-m-d', strtotime($rss_date));
this should do the trick.
Re: Converting rrs-date format to MySQL date format
Posted: Fri Mar 05, 2010 10:31 pm
by mister_v
Hi,
strtotime() doesn't do it for me.
I have the following code:
Code: Select all
$pubdate=date('Y-m-d',strtotime($rssdate));
print $rssdate."\n";
print $pubdate."\n";
Wich results in:
Fri, 5 Mar 2010 08:00:00 System/Localtime
1970-01-01
My php version:
PHP 5.2.6
Re: Converting rrs-date format to MySQL date format
Posted: Sun Mar 07, 2010 7:01 pm
by chris
Hi,
I tested it with php version 5.2.10-2,
and it works OK.
result:
Fri, 5 Mar 2010 08:00:00 System/Localtime
2010-03-05
Try upgrading to the latest version.
Re: Converting rrs-date format to MySQL date format
Posted: Sun Mar 07, 2010 7:10 pm
by chris
As you only need the date.
Try it with only the first part:
Code: Select all
$date_array=explode(' ',$rssdate);
$newdate=$date_array[0].$date_array[1].$date_array[2].$date_array[3];
$pubdate=date('Y-m-d',strtotime($newdate));
print $newdate."\n";
print $pubdate."\n";
It should give a correct result:
Fri,5Mar2010
2010-03-05
Re: Converting rrs-date format to MySQL date format
Posted: Sun Mar 07, 2010 11:17 pm
by mister_v
Thanks,
This works.
It gets the correct date.