FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how format one date
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: how format one date [message #179064 is a reply to message #179063] Fri, 07 September 2012 22:22 Go to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Thomas 'PointedEars' Lahn wrote:

> bill wrote:
>> On 9/7/2012 2:07 PM, Tim Streater wrote:
>>> In article <1guuas2go7c0i$(dot)1aviei1ybpcod$(dot)dlg(at)40tude(dot)net>,
>>> nawfer <novalidsforspam(at)alt(dot)al> wrote:
>>>> Il Fri, 7 Sep 2012 13:48:29 +0000 (UTC), Salvatore ha scritto:
>>>> > On 2012-09-07, nawfer <novalidsforspam(at)alt(dot)al> 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),

OK, bad example. It's not German here, for the weekday is in English. But
you see my point:

> and you get to choose the supported format with strptime(), so there are
> no ambiguities with parsing. […]
> 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).


PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Converting eps to png
Next Topic: Never log deprecation warnings
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 20:37:49 GMT 2024

Total time taken to generate the page: 0.04067 seconds