|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Any suggestions apart from brute force to convert a date like this:
2008-03-23T20:58:50-04:00 to seconds since 1970 ? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Mar 28, 11:41 pm, Duke of Hazard <squ...@peoriadesignweb.com>
wrote: > Any suggestions apart from brute force to convert a date like this: > > 2008-03-23T20:58:50-04:00 > > to seconds since 1970 ? Did some googling and found this, but it give :50 for seconds, instead of 50: function parse_w3cdtf ( $date_str ) { # regex to match wc3dtf $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}) \d{2})( \d{2}))?(? [-+])(\d{2}):?(\d{2})|(Z))?/"; if ( preg_match( $pat, $date_str, $match ) ) { list( $year, $month, $day, $hours, $minutes, $seconds) = array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
..oO(Duke of Hazard)
>Any suggestions apart from brute force to convert a date like this: > >2008-03-23T20:58:50-04:00 > >to seconds since 1970 ? strtotime() Micha |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Duke of Hazard wrote:
> 2008-03-23T20:58:50-04:00 This is not an RSS date. RSS uses RFC-822-style dates, such as: Sun, 30 Mar 2008 19:03:40 +0100 The date format you posted is and ISO-8601 date, as used by e.g. Atom. -- 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 4 days, 5:22.] Cognition 0.1 Alpha 6 http://tobyinkster.co.uk/blog/2008/0...nition-alpha6/ |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Mar 29, 7:41 am, Duke of Hazard <squ...@peoriadesignweb.com> wrote:
> Any suggestions apart from brute force to convert a date like this: > > 2008-03-23T20:58:50-04:00 > > to seconds since 1970 ? Should work with strtotime(). I have a feed parser for both RSS and ATOM and it successfully converts the dates using strtotime(). |
|
![]() |
| Outils de la discussion | |
|
|