473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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
Jun 2 '08 #1
9 1553
On 22 Apr, 14:08, SOLVER <mari...@poplawski.org.ukwrote:
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"))
Jun 2 '08 #2
On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
<ma*****@poplawski.org.ukwrote in
<f4**********************************@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
Jun 2 '08 #3
On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.comwrote:
On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
<mari...@poplawski.org.ukwrote 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.
Jun 2 '08 #4
On Tue, 22 Apr 2008 16:30:10 +0200, Captain Paralytic
<pa**********@yahoo.comwrote:
On 22 Apr, 14:08, SOLVER <mari...@poplawski.org.ukwrote:
>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
Jun 2 '08 #5
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
Jun 2 '08 #6
On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic wrote:
On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.comwrote:
>On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
<mari...@poplawski.org.ukwrote 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 cookie, at least one of your competitors
will run a site which does not. Your competitor will get the sale.
Jun 2 '08 #7
On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic
<pa**********@yahoo.comwrote in
<ca**********************************@m73g2000hsh. googlegroups.com>:
>On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.comwrote:
>On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
<mari...@poplawski.org.ukwrote 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
Jun 2 '08 #8
On 22 Apr, 16:26, Charles Calvert <cb...@yahoo.comwrote:
On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic
<paul_laut...@yahoo.comwrote in
<ca815c6c-c98d-4e5d-acf4-9a0e41726...@m73g2000hsh.googlegroups.com>:
On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.comwrote:
On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
<mari...@poplawski.org.ukwrote 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.
Jun 2 '08 #9
On Wed, 23 Apr 2008 02:57:23 -0700 (PDT), Captain Paralytic
<pa**********@yahoo.comwrote in
<f6**********************************@p25g2000hsf. googlegroups.com>:
>On 22 Apr, 16:26, Charles Calvert <cb...@yahoo.comwrote:
>On Tue, 22 Apr 2008 08:06:25 -0700 (PDT), Captain Paralytic
<paul_laut...@yahoo.comwrote in
<ca815c6c-c98d-4e5d-acf4-9a0e41726...@m73g2000hsh.googlegroups.com>:
>On 22 Apr, 14:44, Charles Calvert <cb...@yahoo.comwrote:
On Tue, 22 Apr 2008 07:08:55 -0700 (PDT), SOLVER
<mari...@poplawski.org.ukwrote 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
Jun 2 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
8
by: Dennis M. Marks | last post by:
What is the maximum valid date range for the date(yyyy,mm,dd) function. -- Dennis M. Marks http://www.dcs-chico.com/~denmarks/ Replace domain.invalid with dcsi.net -----= Posted via...
1
by: windandwaves | last post by:
Hi Folk Some of you may be interested in a function that allows you to add/substract from a date in PHP, using a MySql Dateformat (e.g. 2005-10-31) (NOT TESTED): Any comments appreciated. ...
4
by: ey.markov | last post by:
Greetings, I have an A2K application where for a report the user enters a month-end date, and the system must gather transactions for that month. No problem, I thought, I'll just use the DateAdd...
18
by: jimfortune | last post by:
I have an A97 module called modWorkdayFunctions in: http://www.oakland.edu/~fortune/WorkdayFunctions.zip It allows the counting of workdays taking into consideration up to 11 U.S. holidays. ...
10
by: John Morgan | last post by:
Does anyone know what parameter should be used instead of Date = 0 for the optional parameter in the following function? Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As Date...
11
by: sara | last post by:
I am trying my first functions in my code. I have a set of queries that runs to create temp tables with the right data for some reports. They can run for a long time, so I want the user to know...
18
by: ben.carbery | last post by:
Hi, I have just written a simple program to get me started in C that calculates the number of days since your birthdate. One thing that confuses me about the program (even though it works) is...
3
by: murch.alexander | last post by:
I made a simple public function to set and return a date value (see below). I have a number of queries that call up the function to get the "As Of Date," which is typically set to today's date....
4
by: OzNet | last post by:
I have some functions to calculate the working days in a given period. This includes a table that is queried to calculate the number of public holidays that don’t occur on a weekend. If I test...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.