Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1584824.OSQIn9VdOr@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 08 Sep 2012 00:19:22 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <1guuas2go7c0i$.1aviei1ybpcod$.dlg@40tude.net> Followup-To: comp.lang.php MIME-Version: 1.0 Lines: 57 NNTP-Posting-Date: 08 Sep 2012 00:19:22 CEST NNTP-Posting-Host: 8839dd37.newsspool1.arcor-online.net X-Trace: DXC=lPb8=47<5BRE47KDAk81NWic==]BZ:af^4Fo<]lROoRQnkgeX?EC@@PIRTKiQcV`1TDZm8W4\YJN\R=i2=[N6Y6Z4^f?YmnoooTQOXQGXPfA0P X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.php:6990 bill wrote: > On 9/7/2012 2:07 PM, Tim Streater wrote: >> In article <1guuas2go7c0i$.1aviei1ybpcod$.dlg@40tude.net>, >> nawfer wrote: >>> Il Fri, 7 Sep 2012 13:48:29 +0000 (UTC), Salvatore ha scritto: >>> > On 2012-09-07, nawfer wrote: >>> >> if have one of this date so >>> >> >>> >> Thu, 06/09/2012 - 23:50 >>> >> Thursday, 6 September, 2012 - 23:50 >>> >> Thu, 06/09/2012 - 23:50 >>> >> 06/09/2012 - 23:50 >>> >> >>> >> how can have this >> 2012-09-06T23:50:00 >>> >> >>> >> and finally to have the seconds 1346968200 >>> > > I'm not sure if you're asking how to *format* a date or how >>> > > to *parse* a date. If you want to format a date, given a >>> > > timestamp, use either the date() function or the strftime() >>> > > function. If you want to parse a date, given a string, use >>> > > either the strtotime() function or the strptime() >>> > > function. >>> >>> if have this string >>> "06/09/2012 - 23:50" >> >> Use strtotime () to convert the above into seconds. > then use date() to convert it back to the format you want. In this case, strptime() and strftime() should be used instead because, in contrast to strtotime() and date(), they observe the current locale (note the German month name above), and you get to choose the supported format with strptime(), so there are no ambiguities with parsing. Because in the US-American date format the month comes first (MM/DD/YYYY), strtotime() will return the timestamp for 2012-06-09 23:50, and _not_ 2012-09-06 23:50 as it was probably intended, considering today's date. That is, if, and only if, the hyphen is removed before; else it returns FALSE because that is not one of the formats supported by it. Tested with PHP 5.3.10-1 (cli) (built: Feb 3 2012 10:03:01). Both of those PHP functions are available on all platforms; strftime() since PHP 4, strptime() since PHP 5.1. PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee