PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Function Date
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Function Date

Réponse
 
LinkBack Outils de la discussion
Vieux 22/04/2008, 15h08   #1
SOLVER
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Function Date

Hi,

I can't figure out why this is not working propelly:

date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009
(From where this come from?)

What I'm doing wrong?

Best regards,
Mariusz
  Réponse avec citation
Vieux 22/04/2008, 15h30   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On 22 Apr, 14:08, SOLVER <mari...@poplawski.org.uk> wrote:
> Hi,
>
> I can't figure out why this is not working propelly:
>
> date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
> date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009
> (From where this come from?)
>
> What I'm doing wrong?
>
> Best regards,
> Mariusz


The manual explains it. Try
date("d.m.Y",strtotime("2008-05-18 00:00:00"))
  Réponse avec citation
Vieux 22/04/2008, 15h44   #3
Charles Calvert
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
<mariusz@poplawski.org.uk> wrote in
<f48512ab-77e6-4f34-a3e0-aad33f40d3ef@k37g2000hsf.googlegroups.com>:

>I can't figure out why this is not working propelly:
>
>date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
>date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009


From <http://us2.php.net/manual/en/function.strtotime.php>:

"The function expects to be given a string containing a US English
date format..." The U.S. format is "MM/DD/YYYY", while the European
formation is "DD/MM/YYYY".

Assuming that the first date is March 5, 2008, then you should write:

strtotime("3/5/2008 00:00:00");

The second should be:

strtotime("5/18/2008 00:00:00");

Check out some of the comments on that page for information regarding
European formats.
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
  Réponse avec citation
Vieux 22/04/2008, 16h06   #4
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.com> wrote:
> On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
> <mari...@poplawski.org.uk> wrote in
> <f48512ab-77e6-4f34-a3e0-aad33f40d...@k37g2000hsf.googlegroups.com>:
>
> >I can't figure out why this is not working propelly:

>
> >date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
> >date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009

>
> From <http://us2.php.net/manual/en/function.strtotime.php>:
>
> "The function expects to be given a string containing a US English
> date format..."

But it goes on to say:
The string to parse, according to the GNU » Date Input Formats
syntax.
http://www.gnu.org/software/tar/manu...e/tar_113.html
Which rather contradicts the statement that you quoted.
  Réponse avec citation
Vieux 22/04/2008, 16h27   #5
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER wrote:
> Hi,
>
> I can't figure out why this is not working propelly:
>
> date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008


This is correct.

> date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009


This is day 5 of month 18 of 2008, or 18-12=6 month of 2009.

> (From where this come from?)
>
> What I'm doing wrong?


Not knowing that strtotime is expecting en_us format date, per manual.

http://us3.php.net/strtotime

--
Every fleeting thought you've ever had in your life, no matter how bizarre,
is someone's lifelong obsession. And he has a website.
-- Skif's Internet Theorem
  Réponse avec citation
Vieux 22/04/2008, 16h32   #6
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic wrote:
> On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.com> wrote:
>> On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
>> <mari...@poplawski.org.uk> wrote in
>> <f48512ab-77e6-4f34-a3e0-aad33f40d...@k37g2000hsf.googlegroups.com>:
>>
>> >I can't figure out why this is not working propelly:

>>
>> >date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
>> >date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009

>>
>> From <http://us2.php.net/manual/en/function.strtotime.php>:
>>
>> "The function expects to be given a string containing a US English
>> date format..."

> But it goes on to say:
> The string to parse, according to the GNU » Date Input Formats
> syntax.
> http://www.gnu.org/software/tar/manu...e/tar_113.html
> Which rather contradicts the statement that you quoted.


The only relevant port of that URL is the calendar dates, shown at
http://www.gnu.org/software/tar/manu...15.html#SEC115

None of those have numerical days followed by numerical months. All of
the day-first formats have alpha months. So while it points to differnt
things, for this particular case, the two sections do not contradict.
(I'm not going to address all the other possible contradictions because
those would kill any productivity I may have for the rest of the day...)

--
Graham's First Rule of Internet Retailing:
If your 'shopping cart' site requires anything more complex than
HTML, SSL and a session , at least one of your competitors
will run a site which does not. Your competitor will get the sale.
  Réponse avec citation
Vieux 22/04/2008, 16h54   #7
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On Tue, 22 Apr 2008 16:30:10 +0200, Captain Paralytic
<paul_lautman@yahoo.com> wrote:

> On 22 Apr, 14:08, SOLVER <mari...@poplawski.org.uk> wrote:
>> Hi,
>>
>> I can't figure out why this is not working propelly:
>>
>> date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
>> date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009
>> (From where this come from?)
>>
>> What I'm doing wrong?
>>
>> Best regards,
>> Mariusz

>
> The manual explains it. Try
> date("d.m.Y",strtotime("2008-05-18 00:00:00"))


Indeed. Some insight: dd/dd/dddd is assumed to be mm/dd/yyyy (crazy
Americans...). 2008-18-05 obviously doesn't exist, 18 - 12 = 6, 2008 +1 =
9, hence 2009-06-05.
--
Rik Wasmus
  Réponse avec citation
Vieux 22/04/2008, 17h26   #8
Charles Calvert
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic
<paul_lautman@yahoo.com> wrote in
<ca815c6c-c98d-4e5d-acf4-9a0e4172637b@m73g2000hsh.googlegroups.com>:

>On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.com> wrote:
>> On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
>> <mari...@poplawski.org.uk> wrote in
>> <f48512ab-77e6-4f34-a3e0-aad33f40d...@k37g2000hsf.googlegroups.com>:
>>
>> >I can't figure out why this is not working propelly:

>>
>> >date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
>> >date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009

>>
>> From <http://us2.php.net/manual/en/function.strtotime.php>:
>>
>> "The function expects to be given a string containing a US English
>> date format..."

>
>But it goes on to say:
>The string to parse, according to the GNU » Date Input Formats
>syntax.
>http://www.gnu.org/software/tar/manu...e/tar_113.html
>Which rather contradicts the statement that you quoted.


I don't think it does. If you check the referenced information and
look at the accepted formats
<http://www.gnu.org/software/tar/manual/html_node/tar_115.html#SEC115>,
YYYY-MM-DD and MM/DD/YYYY are both listed as acceptable, but
DD/MM/YYYY is not.

I agree that the statement in the php docs would seems to imply that
it might accept other conventions, but as I read the GNU docs, it
doesn't, at least with numeric months. Did I miss something?

--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
  Réponse avec citation
Vieux 23/04/2008, 10h57   #9
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On 22 Apr, 16:26, Charles Calvert <cb...@yahoo.com> wrote:
> On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic
> <paul_laut...@yahoo.com> wrote in
> <ca815c6c-c98d-4e5d-acf4-9a0e41726...@m73g2000hsh.googlegroups.com>:
>
>
>
> >On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.com> wrote:
> >> On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
> >> <mari...@poplawski.org.uk> wrote in
> >> <f48512ab-77e6-4f34-a3e0-aad33f40d...@k37g2000hsf.googlegroups.com>:

>
> >> >I can't figure out why this is not working propelly:

>
> >> >date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
> >> >date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009

>
> >> From <http://us2.php.net/manual/en/function.strtotime.php>:

>
> >> "The function expects to be given a string containing a US English
> >> date format..."

>
> >But it goes on to say:
> >The string to parse, according to the GNU » Date Input Formats
> >syntax.
> >http://www.gnu.org/software/tar/manu...e/tar_113.html
> >Which rather contradicts the statement that you quoted.

>
> I don't think it does. If you check the referenced information and
> look at the accepted formats


I don't see how you can say "I don't think it does."
The part of he page which you (quite correctly) quoted says:
"The function expects to be given a string containing a US English
date format..."

However, it then goes on to say that it will accept other (non-US
English) formats. Thus it does not expect a US English format, rather
it expects any of the formats listed on the linked page.
  Réponse avec citation
Vieux 23/04/2008, 19h07   #10
Charles Calvert
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Function Date

On Wed, 23 Apr 2008 02:57:23 -0700 (PDT), Captain Paralytic
<paul_lautman@yahoo.com> wrote in
<f69de1cf-514b-4512-a032-b25746ff850d@p25g2000hsf.googlegroups.com>:

>On 22 Apr, 16:26, Charles Calvert <cb...@yahoo.com> wrote:
>> On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic
>> <paul_laut...@yahoo.com> wrote in
>> <ca815c6c-c98d-4e5d-acf4-9a0e41726...@m73g2000hsh.googlegroups.com>:
>>
>> >On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.com> wrote:
>> >> On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
>> >> <mari...@poplawski.org.uk> wrote in
>> >> <f48512ab-77e6-4f34-a3e0-aad33f40d...@k37g2000hsf.googlegroups.com>:

>>
>> >> >I can't figure out why this is not working propelly:

>>
>> >> >date("d.m.Y",strtotime("05/03/2008 00:00:00")); result: 03.05.2008
>> >> >date("d.m.Y",strtotime("18/05/2008 00:00:00")); result: 05.06.2009

>>
>> >> From <http://us2.php.net/manual/en/function.strtotime.php>:

>>
>> >> "The function expects to be given a string containing a US English
>> >> date format..."

>>
>> >But it goes on to say:
>> >The string to parse, according to the GNU » Date Input Formats
>> >syntax.
>> >http://www.gnu.org/software/tar/manu...e/tar_113.html
>> >Which rather contradicts the statement that you quoted.

>>
>> I don't think it does. If you check the referenced information and
>> look at the accepted formats

>
>I don't see how you can say "I don't think it does."
>The part of he page which you (quite correctly) quoted says:
>"The function expects to be given a string containing a US English
>date format..."
>
>However, it then goes on to say that it will accept other (non-US
>English) formats. Thus it does not expect a US English format, rather
>it expects any of the formats listed on the linked page.


Ah, now I understand your point. Thank you for clarifying it for me.
You're quite correct that it will accept formats other than
MM/DD/YYYY, and that some of those formats are not in normal use in
the U.S.

I thought that you were saying that the statement regarding GNU Date
Input Formats implied that it should accept DD/MM/YYYY.
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h55.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,62654 seconds with 18 queries