Re: [PHP] strtotime()

2010-08-23 Thread Daniel Brown
On Tue, Aug 24, 2010 at 00:37, Rick Pasotto  wrote:
>
> http://us2.php.net/manual/en/datetime.formats.relative.php

Thank you, sir!

-- 

UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2010-08-23 Thread Rick Pasotto
On Mon, Aug 23, 2010 at 11:38:41PM -0400, Daniel P. Brown wrote:
> On Mon, Aug 23, 2010 at 22:27, Rick Pasotto  wrote:
> >
> > After I sent my original post the one and only user comment on the
> > relative date strings man page was pointed out to me. So, it's there but
> > how many people make a habit of reading all the user comments?
> 
> A few thousand per day, give or take.
> 
> I do remember seeing which page had the note, but I don't recall
> which one.  Can you send me the link so that I can pop that out and
> put the info in the documentation?

http://us2.php.net/manual/en/datetime.formats.relative.php

-- 
"There are always three speeches, for every one you actually gave. The
 one you practiced, the one you gave, and the one you wish you gave."
-- Dale Carnegie
Rick Pasottor...@niof.nethttp://www.niof.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2010-08-23 Thread Daniel P. Brown
On Mon, Aug 23, 2010 at 22:27, Rick Pasotto  wrote:
>
> After I sent my original post the one and only user comment on the
> relative date strings man page was pointed out to me. So, it's there but
> how many people make a habit of reading all the user comments?

A few thousand per day, give or take.

I do remember seeing which page had the note, but I don't recall
which one.  Can you send me the link so that I can pop that out and
put the info in the documentation?

-- 

UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2010-08-23 Thread Rick Pasotto
On Mon, Aug 23, 2010 at 05:57:28PM -0400, Daniel Brown wrote:
> On Mon, Aug 23, 2010 at 17:02, Ashley Sheridan  
> wrote:
> >
> > The example you quote as being straight from the manual page is actually
> > from the user-submitted code snippets, and I can't find the
> > documentation to support it. I can only assume that it's possibly an
> > experimental thing, or something that shouldn't work but by freak
> > coincidence does occasionally. Maybe use mktime() instead to get the
> > dates?
> 
> Relative date strings - specifically including those terms - are
> in PHP5 >= 5.3.0 exclusively, for now.  I don't believe there are any
> plans to backport it to the 5.2 branch.
> 
> Rick, if you want to add this as a "Documentation Problem" to
> http://bugs.php.net/, one of us will likely add it to the
> documentation, as it probably should not only be noted, but also be in
> an easy-to-find place (you know, such as right there on the
> strtotime() manual entry).

After I sent my original post the one and only user comment on the
relative date strings man page was pointed out to me. So, it's there but
how many people make a habit of reading all the user comments?

Anyway, the following work:

// first day of this month
$t1 = strtotime(date('Y-m',strtotime('this month')));

// last day of next month
// get the first day of month after next and subtract one day
$t2 = strtotime(date('Y-m',$t1 + (86400 * 70)))-86400;

-- 
"I'm so optimistic I'd go after Moby Dick in a row boat and take the
 tartar sauce with me." -- Zig Zigler
Rick Pasottor...@niof.nethttp://www.niof.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2010-08-23 Thread Daniel Brown
On Mon, Aug 23, 2010 at 17:02, Ashley Sheridan  
wrote:
>
> The example you quote as being straight from the manual page is actually
> from the user-submitted code snippets, and I can't find the
> documentation to support it. I can only assume that it's possibly an
> experimental thing, or something that shouldn't work but by freak
> coincidence does occasionally. Maybe use mktime() instead to get the
> dates?

Relative date strings - specifically including those terms - are
in PHP5 >= 5.3.0 exclusively, for now.  I don't believe there are any
plans to backport it to the 5.2 branch.

Rick, if you want to add this as a "Documentation Problem" to
http://bugs.php.net/, one of us will likely add it to the
documentation, as it probably should not only be noted, but also be in
an easy-to-find place (you know, such as right there on the
strtotime() manual entry).

-- 

UNADVERTISED DEDICATED SERVER SPECIALS
SAME-DAY SETUP
Just ask me what we're offering today!
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2010-08-23 Thread Ashley Sheridan
On Mon, 2010-08-23 at 16:04 -0400, Rick Pasotto wrote:

> On my home machine running 5.3.2-2 in debian linux the commands:
> 
> echo date('Y-m-d',strtotime('first day of this month')).'';
> echo date('Y-m-d',strtotime('last day of next month'));
> 
> give the expected results.
> 
> I just got setup with a hosting provider running 5.2.13 on BSD and both
> give '1969-12-31'.
> 
> What could be causing this? The second command is straight from the
> manual and the first is clearly implied.
> 
> So far everything else seems to work as expected.
> 
> -- 
> "Economics is extremely useful as a form of employment for economists."
>   -- John Kenneth Galbraith
> Rick Pasottor...@niof.nethttp://www.niof.net
> 


The example you quote as being straight from the manual page is actually
from the user-submitted code snippets, and I can't find the
documentation to support it. I can only assume that it's possibly an
experimental thing, or something that shouldn't work but by freak
coincidence does occasionally. Maybe use mktime() instead to get the
dates?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] strtotime woes

2010-05-05 Thread Philip Thompson
On May 5, 2010, at 10:12 AM, Peter Lind wrote:

> On 5 May 2010 16:58, Philip Thompson  wrote:
>> Hello all.
>> 
>> Long time no see! Anyway, I'm having an issue with strtotime(). Why do the 
>> following return valid timestamps?
>> 
>> > echo strtotime ('a').': '.date ("m/d/Y", strtotime ('a'))."";
>> echo strtotime ('a,a').': '.date ("m/d/Y", strtotime ('a,a'))."";
>> echo strtotime ('a,a,a').': '.date ("m/d/Y", strtotime ('a,a,a'))."";
>> ?>
>> 
>> These result in today's date:
>> 
>> 1273049449: 05/05/2010
>> 1273049449: 05/05/2010
>> 1273049449: 05/05/2010
>> 
>> Each time the page is reloaded, the seconds jump up... but still today's 
>> date. Why is this? I can repeat the same results by changing the 'a' to any 
>> other single letter: "g" or "h,k" or "r,s,t" or whatever - all the same 
>> result.
>> 
> 
> This was discusses a little while ago, have a look at
> news.php.net/php.general/303839/Logical-reason-for-strtotime-east-and-strtotime-west-returningvalid-results.html
> and the responses.
> 
> Regards
> Peter

Thanks for the link. I did a little bit more research and found a site that may 
help explain what is happening.

http://wwp.greenwichmeantime.com/info/timezone.htm

In the column labeled "Zone" are all the letters of the alphabet (except J). 
So, then I thought to print the times with the date() functions above - they 
were various time(zones). Basically, I think strotime() is just ignoring the 
characters after the first comma in the values above, so then it was finding 
valid timezones. Odd.

Hope this helps someone in the future

Thanks,
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime woes

2010-05-05 Thread Peter Lind
On 5 May 2010 16:58, Philip Thompson  wrote:
> Hello all.
>
> Long time no see! Anyway, I'm having an issue with strtotime(). Why do the 
> following return valid timestamps?
>
>  echo strtotime ('a').': '.date ("m/d/Y", strtotime ('a'))."";
> echo strtotime ('a,a').': '.date ("m/d/Y", strtotime ('a,a'))."";
> echo strtotime ('a,a,a').': '.date ("m/d/Y", strtotime ('a,a,a'))."";
> ?>
>
> These result in today's date:
>
> 1273049449: 05/05/2010
> 1273049449: 05/05/2010
> 1273049449: 05/05/2010
>
> Each time the page is reloaded, the seconds jump up... but still today's 
> date. Why is this? I can repeat the same results by changing the 'a' to any 
> other single letter: "g" or "h,k" or "r,s,t" or whatever - all the same 
> result.
>

This was discusses a little while ago, have a look at
news.php.net/php.general/303839/Logical-reason-for-strtotime-east-and-strtotime-west-returningvalid-results.html
and the responses.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strtotime

2010-01-15 Thread Bob McConnell
There are a variety of starting points available, depending on the
environment and application. See the Computer section of
<http://en.wikipedia.org/wiki/Epoch_%28reference_date%29> for a brief
review.

Bob McConnell

-Original Message-
From: haliphax [mailto:halip...@gmail.com] 
Sent: Thursday, January 14, 2010 4:14 PM
To: php-general@lists.php.net
Subject: Re: [PHP] strtotime

On Thu, Jan 14, 2010 at 2:53 PM, Adam Richardson
wrote:

> I've not read this, but if the first valid date is Jan. 1st, 1970,
then
> passing that date back in the case of errors would lead to ambiguity.
Is
> it
> a valid date or is it an error.  Passing back the date of the day just
> before (in terms of time, I think it's the second before) the first
valid
> date lets you easily identify an error.
>
> Again, I didn't read this anywhere, though, and I could be wrong.
>
> Adam
>
> On Thu, Jan 14, 2010 at 3:47 PM, Kim Madsen  wrote:
>
> > Hi guys
> >
> > I have a question:
> >
> > 
> > Ashley Sheridan wrote on 14/01/2010 19:20:
> >
> > MySQL uses a default "-00-00" value for date fields generally,
but
> > when converted into a timestamp, the string equates to a false
value. In
> > PHP, timestamps are numerical values indicating the seconds since
> > Midnight of the 1st January 1969. As PHP uses loose data typing,
false
> > 
> >
> > Adam Richardson wrote on 14/01/2010 19:25:
> > 
> > 2. date returns 1969, because it's not passed a valid timestamp and
it
> > works from December 31, 1969 for any invalid date.
> > 
> >
> > Why is this? Unixtime starts at January 1st 1970 GMT (see for
instance
> > http://php.net/microtime), I've never heard of the other dates you
> > mentioned.
> >
> > My guess is the time, date or GMT is wrong for Johns setup and
that's why
> > he get 1969 and not 1970, cause something is seting time in the past
>

Time zones. If I have PHP spit out a date for "0" as a string on my
system,
it comes back as 18:00 on December 31st, 1969, because I am in the
Central
time zone.

// Todd

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2010-01-14 Thread John Taylor-Johnston

My thanks to all!

Adam Richardson wrote:
I've not read this, but if the first valid date is Jan. 1st, 1970, 
then passing that date back in the case of errors would lead to 
ambiguity.  Is it a valid date or is it an error.  Passing back the 
date of the day just before (in terms of time, I think it's the second 
before) the first valid date lets you easily identify an error.


Again, I didn't read this anywhere, though, and I could be wrong.

Adam

On Thu, Jan 14, 2010 at 3:47 PM, Kim Madsen @emax.dk > wrote:


Hi guys

I have a question:


Ashley Sheridan wrote on 14/01/2010 19:20:

MySQL uses a default "-00-00" value for date fields generally, but
when converted into a timestamp, the string equates to a false
value. In
PHP, timestamps are numerical values indicating the seconds since
Midnight of the 1st January 1969. As PHP uses loose data typing, false


Adam Richardson wrote on 14/01/2010 19:25:

2. date returns 1969, because it's not passed a valid timestamp
and it works from December 31, 1969 for any invalid date.


Why is this? Unixtime starts at January 1st 1970 GMT (see for
instance http://php.net/microtime), I've never heard of the other
dates you mentioned.

My guess is the time, date or GMT is wrong for Johns setup and
that's why he get 1969 and not 1970, cause something is seting
time in the past

-- 
Kind regards

Kim Emax - masterminds.dk 


-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




--
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] strtotime

2010-01-14 Thread haliphax
On Thu, Jan 14, 2010 at 2:53 PM, Adam Richardson wrote:

> I've not read this, but if the first valid date is Jan. 1st, 1970, then
> passing that date back in the case of errors would lead to ambiguity.  Is
> it
> a valid date or is it an error.  Passing back the date of the day just
> before (in terms of time, I think it's the second before) the first valid
> date lets you easily identify an error.
>
> Again, I didn't read this anywhere, though, and I could be wrong.
>
> Adam
>
> On Thu, Jan 14, 2010 at 3:47 PM, Kim Madsen  wrote:
>
> > Hi guys
> >
> > I have a question:
> >
> > 
> > Ashley Sheridan wrote on 14/01/2010 19:20:
> >
> > MySQL uses a default "-00-00" value for date fields generally, but
> > when converted into a timestamp, the string equates to a false value. In
> > PHP, timestamps are numerical values indicating the seconds since
> > Midnight of the 1st January 1969. As PHP uses loose data typing, false
> > 
> >
> > Adam Richardson wrote on 14/01/2010 19:25:
> > 
> > 2. date returns 1969, because it's not passed a valid timestamp and it
> > works from December 31, 1969 for any invalid date.
> > 
> >
> > Why is this? Unixtime starts at January 1st 1970 GMT (see for instance
> > http://php.net/microtime), I've never heard of the other dates you
> > mentioned.
> >
> > My guess is the time, date or GMT is wrong for Johns setup and that's why
> > he get 1969 and not 1970, cause something is seting time in the past
>

Time zones. If I have PHP spit out a date for "0" as a string on my system,
it comes back as 18:00 on December 31st, 1969, because I am in the Central
time zone.

// Todd


Re: [PHP] strtotime

2010-01-14 Thread Adam Richardson
I've not read this, but if the first valid date is Jan. 1st, 1970, then
passing that date back in the case of errors would lead to ambiguity.  Is it
a valid date or is it an error.  Passing back the date of the day just
before (in terms of time, I think it's the second before) the first valid
date lets you easily identify an error.

Again, I didn't read this anywhere, though, and I could be wrong.

Adam

On Thu, Jan 14, 2010 at 3:47 PM, Kim Madsen  wrote:

> Hi guys
>
> I have a question:
>
> 
> Ashley Sheridan wrote on 14/01/2010 19:20:
>
> MySQL uses a default "-00-00" value for date fields generally, but
> when converted into a timestamp, the string equates to a false value. In
> PHP, timestamps are numerical values indicating the seconds since
> Midnight of the 1st January 1969. As PHP uses loose data typing, false
> 
>
> Adam Richardson wrote on 14/01/2010 19:25:
> 
> 2. date returns 1969, because it's not passed a valid timestamp and it
> works from December 31, 1969 for any invalid date.
> 
>
> Why is this? Unixtime starts at January 1st 1970 GMT (see for instance
> http://php.net/microtime), I've never heard of the other dates you
> mentioned.
>
> My guess is the time, date or GMT is wrong for Johns setup and that's why
> he get 1969 and not 1970, cause something is seting time in the past
>
> --
> Kind regards
> Kim Emax - masterminds.dk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] strtotime

2010-01-14 Thread Kim Madsen

Hi guys

I have a question:


Ashley Sheridan wrote on 14/01/2010 19:20:
MySQL uses a default "-00-00" value for date fields generally, but
when converted into a timestamp, the string equates to a false value. In
PHP, timestamps are numerical values indicating the seconds since
Midnight of the 1st January 1969. As PHP uses loose data typing, false


Adam Richardson wrote on 14/01/2010 19:25:

2. date returns 1969, because it's not passed a valid timestamp and it 
works from December 31, 1969 for any invalid date.



Why is this? Unixtime starts at January 1st 1970 GMT (see for instance 
http://php.net/microtime), I've never heard of the other dates you 
mentioned.


My guess is the time, date or GMT is wrong for Johns setup and that's 
why he get 1969 and not 1970, cause something is seting time in the past


--
Kind regards
Kim Emax - masterminds.dk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2010-01-14 Thread Adam Richardson
When you set the date to "-00-00", you start the following sequence:


   1. strtotime returns false, because "-00-00" isn't a date it can
   parse into a timestamp.
   2. date returns 1969, because it's not passed a valid timestamp and it
   works from December 31, 1969 for any invalid date.


On Thu, Jan 14, 2010 at 1:14 PM, John Taylor-Johnston <
john.taylor-johns...@cegepsherbrooke.qc.ca> wrote:

> Hello,
>
> In a mysql date() field, I set the default to "-00-00".
>
> Therefore, $mydata->birthday = "-00-00";
>
> But when I run this next line, $then = 1969.
>
> $then=date("Y", strtotime($mydata->birthday));
>
> Why 1969, and not 0 or nothing?
>
> If I  echo strtotime("-00-00");
>
> Nothing appears. So $then should be nothing?
>
> What is wrong with my logic?
>
> Thanks,
> John
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] strtotime

2010-01-14 Thread Ashley Sheridan
On Thu, 2010-01-14 at 13:14 -0500, John Taylor-Johnston wrote:

> Hello,
> 
> In a mysql date() field, I set the default to "-00-00".
> 
> Therefore, $mydata->birthday = "-00-00";
> 
> But when I run this next line, $then = 1969.
> 
> $then=date("Y", strtotime($mydata->birthday));
> 
> Why 1969, and not 0 or nothing?
> 
> If I  echo strtotime("-00-00");
> 
> Nothing appears. So $then should be nothing?
> 
> What is wrong with my logic?
> 
> Thanks,
> John
> 


MySQL uses a default "-00-00" value for date fields generally, but
when converted into a timestamp, the string equates to a false value. In
PHP, timestamps are numerical values indicating the seconds since
Midnight of the 1st January 1969. As PHP uses loose data typing, false
is converted to a 0 (zero),and strtotime("-00-00") returns false. As
such, it is treated as the date when time began (for the PHP date object
at least).

There's nothing wrong with your logic, but if you want to check for
empty values, then you should use an extra if statement to check if
strtotime("-00-00") === false

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] strtotime - assumptions about default formatting of dates

2010-01-04 Thread Pete Ford

On 24/12/09 16:59, Bastien Koert wrote:

On Thu, Dec 24, 2009 at 9:12 AM, tedd  wrote:

At 10:20 PM +1000 12/24/09, Angus Mann wrote:


Hi all. I need to allow users to enter dates and times, and for a while
now I've been forcing them to use javascript date/time pickers so I can be
absolutely sure the formatting is correct.

Some users are requesting to be able to type the entries themselves so
I've decided to allow this.

I'm in Australia, and the standard formatting of dates here is DD/MM/
or DD-MM-

I recognize this is different to what seems to happen in the US, where it
is MM/DD/ or MM-DD-

When I process an entered date using strtotime() it seems to work fine.

But of course I am concerned when dates like January 2 come up.

I find that 2/1/2009 is interpreted as January 2, 2009 on my installation,
which is Windows 7 with location set to Australia.

But can I be sure that all installations of PHP, perhaps in different
countries and on different operating systems will interpret dates the same?

I can't find much mention of this question online or in the manual.

Any help much appreciated.
Angus


Angus:

You are running into a problem that cannot be solved by allowing the user to
do whatever they want. As you realize, if I enter 01-02-09 you don't know if
I mean January 2, 2009 or February 1, 2009 and there is no way to figure out
what I meant.

The solution is simply to use the html  and give the user that way
to enter month and day.

I would set it to day-month-year and let US visitors live with it for I
personally think that's a better format.

Cheers and Merry Christmas.

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




I would agree with tedd. Use a JS calendar widget (requires js) or use
three select boxes for mm , dd and year



I developed my little text input AJAX (see earlier post) to work around the fact 
that a LOT of users I encountered were cheesed off by JS calendar widgets, 
especially when the date to be entered was a long way from the current date 
(such as a date of birth). I tried implementing some scroll-wheel events to 
speed up year selection on one of these but it was tricky to get cross-browser 
support.


Drop-downs are a pain when you have to scroll back 40+ years to find the right 
one and are implicitly limited by how far back and forward the designer expects 
to need, and then you have the problem of validating the days and months (which, 
to be fair, is a pretty simple javascript task)


I suspect that with a bit of thought I could put together a Javascript date 
validator that parsed most possible inputs and produced a sensible 
interpretation of them, but I was lazy and had AJAX machinery set up already in 
my project.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime - assumptions about default formatting of dates

2009-12-24 Thread Bastien Koert
On Thu, Dec 24, 2009 at 9:12 AM, tedd  wrote:
> At 10:20 PM +1000 12/24/09, Angus Mann wrote:
>>
>> Hi all. I need to allow users to enter dates and times, and for a while
>> now I've been forcing them to use javascript date/time pickers so I can be
>> absolutely sure the formatting is correct.
>>
>> Some users are requesting to be able to type the entries themselves so
>> I've decided to allow this.
>>
>> I'm in Australia, and the standard formatting of dates here is DD/MM/
>> or DD-MM-
>>
>> I recognize this is different to what seems to happen in the US, where it
>> is MM/DD/ or MM-DD-
>>
>> When I process an entered date using strtotime() it seems to work fine.
>>
>> But of course I am concerned when dates like January 2 come up.
>>
>> I find that 2/1/2009 is interpreted as January 2, 2009 on my installation,
>> which is Windows 7 with location set to Australia.
>>
>> But can I be sure that all installations of PHP, perhaps in different
>> countries and on different operating systems will interpret dates the same?
>>
>> I can't find much mention of this question online or in the manual.
>>
>> Any help much appreciated.
>> Angus
>
> Angus:
>
> You are running into a problem that cannot be solved by allowing the user to
> do whatever they want. As you realize, if I enter 01-02-09 you don't know if
> I mean January 2, 2009 or February 1, 2009 and there is no way to figure out
> what I meant.
>
> The solution is simply to use the html  and give the user that way
> to enter month and day.
>
> I would set it to day-month-year and let US visitors live with it for I
> personally think that's a better format.
>
> Cheers and Merry Christmas.
>
> tedd
>
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I would agree with tedd. Use a JS calendar widget (requires js) or use
three select boxes for mm , dd and year

-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime - assumptions about default formatting of dates

2009-12-24 Thread tedd

At 10:20 PM +1000 12/24/09, Angus Mann wrote:
Hi all. I need to allow users to enter dates and times, and for a 
while now I've been forcing them to use javascript date/time pickers 
so I can be absolutely sure the formatting is correct.


Some users are requesting to be able to type the entries themselves 
so I've decided to allow this.


I'm in Australia, and the standard formatting of dates here is 
DD/MM/ or DD-MM-


I recognize this is different to what seems to happen in the US, 
where it is MM/DD/ or MM-DD-


When I process an entered date using strtotime() it seems to work fine.

But of course I am concerned when dates like January 2 come up.

I find that 2/1/2009 is interpreted as January 2, 2009 on my 
installation, which is Windows 7 with location set to Australia.


But can I be sure that all installations of PHP, perhaps in 
different countries and on different operating systems will 
interpret dates the same?


I can't find much mention of this question online or in the manual.

Any help much appreciated.
Angus


Angus:

You are running into a problem that cannot be solved by allowing the 
user to do whatever they want. As you realize, if I enter 01-02-09 
you don't know if I mean January 2, 2009 or February 1, 2009 and 
there is no way to figure out what I meant.


The solution is simply to use the html  and give the user 
that way to enter month and day.


I would set it to day-month-year and let US visitors live with it for 
I personally think that's a better format.


Cheers and Merry Christmas.

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime - assumptions about default formatting of dates

2009-12-24 Thread Daniel Egeberg
On Thu, Dec 24, 2009 at 13:20, Angus Mann  wrote:
> Hi all. I need to allow users to enter dates and times, and for a while now 
> I've been forcing them to use javascript date/time pickers so I can be 
> absolutely sure the formatting is correct.
>
> Some users are requesting to be able to type the entries themselves so I've 
> decided to allow this.
>
> I'm in Australia, and the standard formatting of dates here is DD/MM/ or 
> DD-MM-
>
> I recognize this is different to what seems to happen in the US, where it is 
> MM/DD/ or MM-DD-
>
> When I process an entered date using strtotime() it seems to work fine.
>
> But of course I am concerned when dates like January 2 come up.
>
> I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, 
> which is Windows 7 with location set to Australia.
>
> But can I be sure that all installations of PHP, perhaps in different 
> countries and on different operating systems will interpret dates the same?
>
> I can't find much mention of this question online or in the manual.
>
> Any help much appreciated.
> Angus
>

strtotime() interprets dates according to the rules of the current
timezone. The specific rules are outlined in GNU's manual:
http://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html

-- 
Daniel Egeberg

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-05 Thread Daniel Brown
On Mon, Oct 5, 2009 at 12:15, Jim Lucas  wrote:
>
> You stated that you are running PHP 5.2.10 , too bad the function recommend
> (locale_get_default()) is only available in PHP 5.3 or newer.

That's my fault entirely, not Floyd's.  I didn't look to see what
version of PHP he was running.

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-05 Thread Jim Lucas
Floyd Resler wrote:
> Well that's odd.  locale_get_default() gave me an undefined function
> error.  Apparently this year problem  has been reported as a bug on
> bugs.php.net but the status for it (and everything else) is Bogus.  I'm
> not sure if that means anything or not but hopefully a fix will be
> coming soon.
> 

You stated that you are running PHP 5.2.10 , too bad the function recommend
(locale_get_default()) is only available in PHP 5.3 or newer.


> Thanks!
> Floyd
> 
> On Oct 5, 2009, at 9:54 AM, Daniel Brown wrote:
> 
>> On Sun, Oct 4, 2009 at 17:00, Floyd Resler  wrote:
>>> Sorry to hear that!  I live in Cincinnati so I normally don't get to
>>> watch
>>> the Colts play when they are on at the same time as the Bengals.  But
>>> this
>>> week I did and, best of all, they won!
>>
>>Yeah, well, the Browns sure didn't, so bite me.  I've got the
>> Vikes tonight, though going to be awesome!
>>
>>In any case, as Andrea suggested, make sure your locale settings
>> haven't changed.  Check:
>>
>> 
>>
>> and
>>
>> 
>>
>> -- 
>> 
>> daniel.br...@parasane.net || danbr...@php.net
>> http://www.parasane.net/ || http://www.pilotpig.net/
>> Check out our great hosting and dedicated server deals at
>> http://twitter.com/pilotpig
>>
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-05 Thread Floyd Resler
Well that's odd.  locale_get_default() gave me an undefined function  
error.  Apparently this year problem  has been reported as a bug on bugs.php.net 
 but the status for it (and everything else) is Bogus.  I'm not sure  
if that means anything or not but hopefully a fix will be coming soon.


Thanks!
Floyd

On Oct 5, 2009, at 9:54 AM, Daniel Brown wrote:

On Sun, Oct 4, 2009 at 17:00, Floyd Resler   
wrote:
Sorry to hear that!  I live in Cincinnati so I normally don't get  
to watch
the Colts play when they are on at the same time as the Bengals.   
But this

week I did and, best of all, they won!


   Yeah, well, the Browns sure didn't, so bite me.  I've got the
Vikes tonight, though going to be awesome!

   In any case, as Andrea suggested, make sure your locale settings
haven't changed.  Check:



    and



--

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-05 Thread Daniel Brown
On Sun, Oct 4, 2009 at 17:00, Floyd Resler  wrote:
> Sorry to hear that!  I live in Cincinnati so I normally don't get to watch
> the Colts play when they are on at the same time as the Bengals.  But this
> week I did and, best of all, they won!

Yeah, well, the Browns sure didn't, so bite me.  I've got the
Vikes tonight, though going to be awesome!

In any case, as Andrea suggested, make sure your locale settings
haven't changed.  Check:



 and



-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-04 Thread Floyd Resler
Sorry to hear that!  I live in Cincinnati so I normally don't get to  
watch the Colts play when they are on at the same time as the  
Bengals.  But this week I did and, best of all, they won!


On Oct 4, 2009, at 3:24 PM, Eddie Drapkin wrote:

On Sun, Oct 4, 2009 at 3:22 PM, Floyd Resler   
wrote:
Yeah, the ;Y" was a typo in my email.  That's what happens while  
trying to

type while watching my Colts play!

Thanks!
Floyd



Go Colts!

At least you get to watch it, I have to follow along on sports sites!




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-04 Thread Eddie Drapkin
On Sun, Oct 4, 2009 at 3:22 PM, Floyd Resler  wrote:
> Yeah, the ;Y" was a typo in my email.  That's what happens while trying to
> type while watching my Colts play!
>
> Thanks!
> Floyd
>

Go Colts!

At least you get to watch it, I have to follow along on sports sites!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-04 Thread Floyd Resler
Yeah, the ;Y" was a typo in my email.  That's what happens while  
trying to type while watching my Colts play!


Thanks!
Floyd

On Oct 4, 2009, at 3:06 PM, Tommy Pham wrote:


- Original Message 

From: Floyd Resler 
To: Andrea Giammarchi 
Cc: php-general@lists.php.net
Sent: Sun, October 4, 2009 12:01:30 PM
Subject: Re: [PHP] strtotime strangeness

I couldn't find anything in the php.ini file to account for this.   
I am running
PHP 5.2.10.  I've never actually updated it myself so the software  
updater

updated it at some point.  I did a little test and found out that
date(:Y",$timestamp) returns .  However, date("y",$timestamp)  
returns the
two digit year properly.  So it seems there is an issue with the  
four digit

year.

Thanks!
Floyd




i hope :Y" is a typo in the email and not in your code.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-04 Thread Tommy Pham
- Original Message 
> From: Floyd Resler 
> To: Andrea Giammarchi 
> Cc: php-general@lists.php.net
> Sent: Sun, October 4, 2009 12:01:30 PM
> Subject: Re: [PHP] strtotime strangeness
> 
> I couldn't find anything in the php.ini file to account for this.  I am 
> running 
> PHP 5.2.10.  I've never actually updated it myself so the software updater 
> updated it at some point.  I did a little test and found out that 
> date(:Y",$timestamp) returns .  However, date("y",$timestamp) returns the 
> two digit year properly.  So it seems there is an issue with the four digit 
> year.
> 
> Thanks!
> Floyd
> 


i hope :Y" is a typo in the email and not in your code.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime strangeness

2009-10-04 Thread Floyd Resler
I couldn't find anything in the php.ini file to account for this.  I  
am running PHP 5.2.10.  I've never actually updated it myself so the  
software updater updated it at some point.  I did a little test and  
found out that date(:Y",$timestamp) returns .  However, date("y", 
$timestamp) returns the two digit year properly.  So it seems there is  
an issue with the four digit year.


Thanks!
Floyd

On Oct 4, 2009, at 2:14 PM, Andrea Giammarchi wrote:

Did the OS update changed the default locale settings or the default  
date format?


> From: fres...@adex-intl.com
> To: php-general@lists.php.net
> Date: Sun, 4 Oct 2009 14:05:05 -0400
> Subject: [PHP] strtotime strangeness
>
> For some reason the strtotime is no longer returning the year
> portion. For example, strtotime("10/04/2009") will result in a date
> of -10-04. This started happening recently and I haven't done  
any

> updates other than the normal OS updates. I am running Mac OS X
> 10.5.8. Does anyone have any ideas or do I just need to install the
> latest version of PHP?
>
> Thanks!
> Floyd
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Windows Live: Make it easier for your friends to see what you’re up  
to on Facebook.




RE: [PHP] strtotime strangeness

2009-10-04 Thread Andrea Giammarchi

Did the OS update changed the default locale settings or the default date 
format?

> From: fres...@adex-intl.com
> To: php-general@lists.php.net
> Date: Sun, 4 Oct 2009 14:05:05 -0400
> Subject: [PHP] strtotime strangeness
> 
> For some reason the strtotime is no longer returning the year  
> portion.  For example, strtotime("10/04/2009") will result in a date  
> of -10-04.  This started happening recently and I haven't done any  
> updates other than the normal OS updates.  I am running Mac OS X  
> 10.5.8.  Does anyone have any ideas or do I just need to install the  
> latest version of PHP?
> 
> Thanks!
> Floyd
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
  
_
Windows Live: Make it easier for your friends to see what you’re up to on 
Facebook.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009

Re: [PHP] strtotime problem

2008-10-10 Thread Thodoris Goltsios



Greetings, Thodoris.
In reply to Your message dated Wednesday, October 8, 2008, 16:35:40,


  


Greetings to you too :-) .

From your function name I assume you want to use it in MySQL. In that
case, why don't you have MySQL do all the magic for you?
eg. INSERT INTO table (col) VALUES (FROM_UNIXTIME($timestamp));
(using FROM_UNIXTIME($timestamp) will give you the date-time in "mysql 
format" (-MM-DD HH:MM:SS) or any other format (if given via the 
2nd parameter)


  


  


Well actually the basic question was if there is about how to change the 
user input rather then how to retrieve the data.


As for the retrieved data: Those functions belong to framework and by 
changing just a function I can retrieve whatever format I need by 
changing a function instead of changing all the queries in the project.


So I guess I will stick with that although I am aware of the date-time 
functions that mysql has available.



Well I have made these two functions to solve this:



  

function dateMysqlToWeb($mysqldate){



  

$format = 'd/m/Y';
$timestamp = strtotime($mysqldate);



  

return date($format,$timestamp);



  

}



Use SQL DATE_FORMAT instead.
Remember: Request the data you need, not the data stored.

  


BTW it was a good suggestion but that is not always true.


function dateWebToMysql($webdate){

   
  

$format = 'Y-m-d';
$date_part = explode("/",$webdate);
$timestamp = mktime(0,0,0,$date_part[1],$date_part[0],$date_part[2]);



  

return date($format,$timestamp);



  

}



  
My basic problem was how to make the user input from a form into a 
timestamp not how to use it with mysql. Since the format used here is 
dd/mm/ I can't use the strtotime directly bacause as far as I know 
from the documentation I don't think that it changes with the timezone 
(as Stut suggested). So since strtotime understands all these variations 
like:



  

mm/dd/, m/d/yy, mm/d/yy etc



Very basic solution: use 3 editboxes and short javascript sample to confirm
input.
Like
[__]/[__]/[]
...
And fill 'timeconfirm' in onchange/onkeypress event, using verbal format like
Tue, Jan 03, 2008

That way, user actually see which date s/he have entered and you may use it
straightforward.
  


This is possible since strtotime accepts many formats and if one of them 
was dd/mm/ it would work like charm.


Nevertheless I made a javascript to chose the date directly from a 
window by just clicking it. In addition to that I will have to validate 
the form data before the insert no matter what javascript does.
  
I can't use this flexible behavior to get the input if it is not in the 
American format (and correct me if I am wrong). If I explode I will have 
to use the fixed format dd/mm/ and I can't use other input formats 
beside this so I lose this flexible approach.



  

It does work for me now but I was wondering if there was a way to avoid
this.



Not as I know. So, you should either force user to use specific format
(military -MM-DD HH:MM:SS for example) or leave user no chance to enter
wrong data.


  


I am already doing that but it would much more convenient if the format 
we usually use here (dd/mm/) was acceptable depending on the 
timezone as Stut suggested somewhere in this thread.


Re: [PHP] strtotime problem

2008-10-08 Thread Thodoris




From your function name I assume you want to use it in MySQL. In that 
case, why don't you have MySQL do all the magic for you?

eg. INSERT INTO table (col) VALUES (FROM_UNIXTIME($timestamp));
(using FROM_UNIXTIME($timestamp) will give you the date-time in "mysql 
format" (-MM-DD HH:MM:SS) or any other format (if given via the 
2nd parameter)




Well I have made these two functions to solve this:

function dateMysqlToWeb($mysqldate){

   $format = 'd/m/Y';
   $timestamp = strtotime($mysqldate);

   return date($format,$timestamp);

}

function dateWebToMysql($webdate){
  
   $format = 'Y-m-d';

   $date_part = explode("/",$webdate);
   $timestamp = mktime(0,0,0,$date_part[1],$date_part[0],$date_part[2]);

   return date($format,$timestamp);

}

My basic problem was how to make the user input from a form into a 
timestamp not how to use it with mysql. Since the format used here is 
dd/mm/ I can't use the strtotime directly bacause as far as I know 
from the documentation I don't think that it changes with the timezone 
(as Stut suggested). So since strtotime understands all these variations 
like:


mm/dd/, m/d/yy, mm/d/yy etc

I can't use this flexible behavior to get the input if it is not in the 
American format (and correct me if I am wrong). If I explode I will have 
to use the fixed format dd/mm/ and I can't use other input formats 
beside this so I lose this flexible approach.


It does work for me now but I was wondering if there was a way to avoid 
this.


--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime problem

2008-10-08 Thread Maciek Sokolewicz

Thodoris wrote:




Actually strtotime accepts all kinds of things... "Last week 
Thursday midnight" for example works perfectly.


You could do an explode on the field and then reorder the array 
anyway that you want...




Or something like that :)

That wasn't tested but should give you an idea...

php.net/explode for more info.






This is what I was doing before (which is a bit lame) so I am looking 
for a more elegant way using timestamps.


Well, If it's not already a timestamp, you can use mktime() to make it 
one, once it is then you should just be able to:




Of course this means that I will explode the date anyway so I will not 
need the intermediate transformation into timestamp.



to format and display it. I'm using that on a time card application 
right now and it's working great.


Is that more what you are looking for?




Actually this means that strtotime() was made with Americans *only* in 
mind... :-) .




From your function name I assume you want to use it in MySQL. In that 
case, why don't you have MySQL do all the magic for you?

eg. INSERT INTO table (col) VALUES (FROM_UNIXTIME($timestamp));
(using FROM_UNIXTIME($timestamp) will give you the date-time in "mysql 
format" (-MM-DD HH:MM:SS) or any other format (if given via the 2nd 
parameter)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime problem

2008-10-08 Thread Jason Pruim


On Oct 8, 2008, at 7:58 AM, Thodoris wrote:





Actually strtotime accepts all kinds of things... "Last week  
Thursday midnight" for example works perfectly.


You could do an explode on the field and then reorder the array  
anyway that you want...




Or something like that :)

That wasn't tested but should give you an idea...

php.net/explode for more info.






This is what I was doing before (which is a bit lame) so I am  
looking for a more elegant way using timestamps.


Well, If it's not already a timestamp, you can use mktime() to make  
it one, once it is then you should just be able to:




Of course this means that I will explode the date anyway so I will  
not need the intermediate transformation into timestamp.


I was just giving that as an option incase it's not already a  
timestamp :)


I usually convert to timestamps as soon as the dates are given to the  
application and store them in the database.





to format and display it. I'm using that on a time card application  
right now and it's working great.


Is that more what you are looking for?




Actually this means that strtotime() was made with Americans only in  
mind... :-) .


As an American, I don't see a big issue with that :P But what Stut  
said is more then likely true... :)






--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]






Re: [PHP] strtotime problem

2008-10-08 Thread Stut

On 8 Oct 2008, at 12:58, Thodoris wrote:
Actually this means that strtotime() was made with Americans *only*  
in mind... :-) .


As far as I know it uses the configured timezone to decide between  
ambiguous formats.


-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime problem

2008-10-08 Thread Thodoris




Actually strtotime accepts all kinds of things... "Last week 
Thursday midnight" for example works perfectly.


You could do an explode on the field and then reorder the array 
anyway that you want...




Or something like that :)

That wasn't tested but should give you an idea...

php.net/explode for more info.






This is what I was doing before (which is a bit lame) so I am looking 
for a more elegant way using timestamps.


Well, If it's not already a timestamp, you can use mktime() to make it 
one, once it is then you should just be able to:




Of course this means that I will explode the date anyway so I will not 
need the intermediate transformation into timestamp.



to format and display it. I'm using that on a time card application 
right now and it's working great.


Is that more what you are looking for?




Actually this means that strtotime() was made with Americans *only* in 
mind... :-) .


--
Thodoris



Re: [PHP] strtotime problem

2008-10-08 Thread Jason Pruim


On Oct 8, 2008, at 7:08 AM, Thodoris wrote:

I know that *strtotime*() only recognises the formats mm/dd/,  
-mm-dd and mmdd

for numeric months but I need do something like that:

function dateWebToMysql($webdate){

$format = 'Y-m-d';
$timestamp = strtotime($webdate);

return date($format,$timestamp);

}

print dateWebToMysql('01/03/2008');

Where 01/03/2008 is in dd/mm/ format (not the American format).  
What is the best way of doing this?


Any ideas?


Actually strtotime accepts all kinds of things... "Last week Thursday  
midnight" for example works perfectly.


You could do an explode on the field and then reorder the array anyway  
that you want...




Or something like that :)

That wasn't tested but should give you an idea...

php.net/explode for more info.






--
Thodoris



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime problem

2008-10-08 Thread Jason Pruim


On Oct 8, 2008, at 7:24 AM, Thodoris wrote:





On Oct 8, 2008, at 7:08 AM, Thodoris wrote:

I know that *strtotime*() only recognises the formats mm/dd/,  
-mm-dd and mmdd

for numeric months but I need do something like that:

function dateWebToMysql($webdate){

   $format = 'Y-m-d';
   $timestamp = strtotime($webdate);
   return date($format,$timestamp);
   }

print dateWebToMysql('01/03/2008');

Where 01/03/2008 is in dd/mm/ format (not the American  
format). What is the best way of doing this?


Any ideas?


Actually strtotime accepts all kinds of things... "Last week  
Thursday midnight" for example works perfectly.


You could do an explode on the field and then reorder the array  
anyway that you want...




Or something like that :)

That wasn't tested but should give you an idea...

php.net/explode for more info.






This is what I was doing before (which is a bit lame) so I am  
looking for a more elegant way using timestamps.


Well, If it's not already a timestamp, you can use mktime() to make it  
one, once it is then you should just be able to:




to format and display it. I'm using that on a time card application  
right now and it's working great.


Is that more what you are looking for?

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime problem

2008-10-08 Thread Thodoris




On Oct 8, 2008, at 7:08 AM, Thodoris wrote:

I know that *strtotime*() only recognises the formats mm/dd/, 
-mm-dd and mmdd

for numeric months but I need do something like that:

function dateWebToMysql($webdate){

$format = 'Y-m-d';
$timestamp = strtotime($webdate);

return date($format,$timestamp);

}


print dateWebToMysql('01/03/2008');

Where 01/03/2008 is in dd/mm/ format (not the American format). 
What is the best way of doing this?


Any ideas?


Actually strtotime accepts all kinds of things... "Last week Thursday 
midnight" for example works perfectly.


You could do an explode on the field and then reorder the array anyway 
that you want...




Or something like that :)

That wasn't tested but should give you an idea...

php.net/explode for more info.






This is what I was doing before (which is a bit lame) so I am looking 
for a more elegant way using timestamps.


--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime( 'last Sunday' ) and republicans

2008-03-13 Thread David Giragosian
On 3/13/08, tedd <[EMAIL PROTECTED]> wrote:
> At 10:43 AM -0500 3/12/08, Greg Donald wrote:
> >No matter where we draw the borders or put the roads and highways,
> >it's still just the one planet, with the same finite resources we all
> >have to share.  Being mad about globalization is pointless, it's
> >inevitable.
>
> Not if you don't live on this planet.

Tried that. Didn't work. Sent home.

;-{

-- 

-David.

When the power of love
overcomes the love of power,
the world will know peace.

-Jimi Hendrix

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime( 'last Sunday' ) and republicans

2008-03-13 Thread Robert Cummings

On Thu, 2008-03-13 at 11:49 -0400, tedd wrote:
> At 10:43 AM -0500 3/12/08, Greg Donald wrote:
> >No matter where we draw the borders or put the roads and highways,
> >it's still just the one planet, with the same finite resources we all
> >have to share.  Being mad about globalization is pointless, it's
> >inevitable.
> 
> Not if you don't live on this planet.

I'm pretty sure all planets have finite resources.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime( 'last Sunday' ) and republicans

2008-03-13 Thread tedd

At 10:43 AM -0500 3/12/08, Greg Donald wrote:

No matter where we draw the borders or put the roads and highways,
it's still just the one planet, with the same finite resources we all
have to share.  Being mad about globalization is pointless, it's
inevitable.


Not if you don't live on this planet.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime( 'last Sunday' ) and republicans

2008-03-12 Thread Greg Donald
On 3/10/08, Wolf <[EMAIL PROTECTED]> wrote:
> Watch throwing that blame around there Greg, you get to thank the
>  democrats for NAFTA and the hurting the heartlands

No matter where we draw the borders or put the roads and highways,
it's still just the one planet, with the same finite resources we all
have to share.  Being mad about globalization is pointless, it's
inevitable.


-- 
Greg Donald
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime( 'last Sunday' ) and republicans

2008-03-10 Thread Wolf


Greg Donald wrote:

Hey Rob,

Remember on 2007-09-18 at 22:45:37 when you suggested I do this:

http://marc.info/?l=php-general&m=119015558426248&w=2

Well.. today strtotime( 'last Sunday' ) screwed me and I'm writing to
say that I nearly fell out of my chair laughing when I realized what
the problem was, who caused it, and who "helped" me code it. :)

This issue only appears on an ancient PHP4 install as far as I can tell:

echo "Current time():\n";
echo date( 'Y-m-d H:i:s', time() );
echo "\nBroken strtotime( 'last Sunday' )\n";
echo date( 'Y-m-d H:i:s', strtotime( 'last Sunday' ) );
echo "\n";


/usr/local/php4/bin/php test.php

Current time():
2008-03-10 20:03:39
Broken strtotime( 'last Sunday' )
2008-03-08 23:00:00

23:00?  Guess what we did to out clocks this past weekend?

I blame the republicans in general, and the short one named 'W' specifically.

I won't bother mentioning the fix as I'm sure 83,293,874,713 people
will post the same correct code by the end of the day tomorrow.  No
one runs PHP4 except _my_ clients anyway.  *shrug*



Watch throwing that blame around there Greg, you get to thank the 
democrats for NAFTA and the hurting the heartlands including the one 
who's running now and controlled her man by the short hairs...  well I 
guess Monica did that..  And she's pimping out her daughter...  ;)


And yeah, the code is out there for all the daylight savings changes...  ;)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2008-02-14 Thread Richard Lynch
I would use date and mktime, personally, as strtotime often does
things I consider "strange"

On Sun, February 10, 2008 5:46 am, Ron Piggott wrote:
>
> I am trying to calculate what was the date 18 months ago.  When I give
> the command:
>
> $18_months_ago = strtotime("-18 months");
>
> It comes back with:
>
> Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE
>
> How would you calculate 18 months ago from today?
>
> Ron
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2008-02-10 Thread Ron Piggott

The date value I was assigning was for a mySQL query ... a date range
query.  I was running my query when I hadn't assigned a date to the
other date range variable.  I didn't realized I hadn't copied my DATE()
syntax to this area of my code.  Ron

On Sun, 2008-02-10 at 18:22 +0100, Floor Terra wrote:
> On 2/10/08, Ron Piggott <[EMAIL PROTECTED]> wrote:
> > I figured out what went wrong.  Ron
> >
> Care to share it with us?
> 
> Floor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2008-02-10 Thread Floor Terra
On 2/10/08, Ron Piggott <[EMAIL PROTECTED]> wrote:
> I figured out what went wrong.  Ron
>
Care to share it with us?

Floor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2008-02-10 Thread Per Jessen
Ron Piggott wrote:

> 
> I am trying to calculate what was the date 18 months ago.  When I give
> the command:
> 
> $18_months_ago = strtotime("-18 months");
> 
> It comes back with:
> 
> Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE

That's a plain syntactical error, it's not related to strtotime().  Your
variable name of '18_months_ago' is not valid in PHP.



/Per Jessen, Zürich

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....

2008-01-31 Thread Richard Lynch
On Thu, January 31, 2008 3:29 pm, Mike Morton wrote:
> Except that generally, when am told "next Saturday" - I take that to
> mean
> "the next Saturday" - just one more ambiguity in the english language
> that
> makes it so hard to learn I suppose!

strtotime has always seemed to me like it's bordering on trying to do
"too much"...

I mean, it's practically trying to solve an NLP (Natural Language
Processing) problem, which AI researchers have spent decades and
billions trying to "solve" and they are not exactly getting the
(impossible) job done...

So I never rely on strtotime(), and use something simple like basic
arithmetic to compute days.

It takes out all the ambiguity since Saturday is always day 6 and
adding 7 always ends up on another Saturday.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....

2008-01-31 Thread Jochem Maas

Mike Morton schreef:

Good point ;)

Except that generally, when am told "next Saturday" - I take that to mean
"the next Saturday" - just one more ambiguity in the english language that
makes it so hard to learn I suppose!

The odd thing about this whole situation it that it seems to have cropped up
just after we "upgraded" to 4.3.9 - prior to that, "next Saturday" worked
just peachy.  I wish I knew which version we were running before that - but
that record was not kept.

I guess we are stuck with this, what maybe is a problem with this version,
until the Redhat RPM gets higher than 4.3.9 - since that is what our server
manager uses for updates

I could always adjust it to be:

date("m/d/Y",strtotime("+ ".(6-date("w"))." days"));

That should always return the next Saturday of the week, and if I am correct
in my thinking, then even on the Saturday, 6-6 = 0 - which would return that
day... Which does, at least for my application of it, work.


so your actually saying 'find the closest saturday, in the future, from today'.
because if it was saturday, and you said to me "see you next saterday" I'd 
expect
to see you in 7 days time.





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....

2008-01-31 Thread Mike Morton
Good point ;)

Except that generally, when am told "next Saturday" - I take that to mean
"the next Saturday" - just one more ambiguity in the english language that
makes it so hard to learn I suppose!

The odd thing about this whole situation it that it seems to have cropped up
just after we "upgraded" to 4.3.9 - prior to that, "next Saturday" worked
just peachy.  I wish I knew which version we were running before that - but
that record was not kept.

I guess we are stuck with this, what maybe is a problem with this version,
until the Redhat RPM gets higher than 4.3.9 - since that is what our server
manager uses for updates

I could always adjust it to be:

date("m/d/Y",strtotime("+ ".(6-date("w"))." days"));

That should always return the next Saturday of the week, and if I am correct
in my thinking, then even on the Saturday, 6-6 = 0 - which would return that
day... Which does, at least for my application of it, work.

I am not sure how the bug that "next" = +2 rather than +1 applys here, maybe
it is just not understanding how exactly the "next whatever" syntax is
applied


On 1/31/08 12:57 PM, "Richard Lynch" <[EMAIL PROTECTED]> wrote:

> Maybe it's just me, but I've never quite figured out what people mean
> when they say "next Saturday"...
> 
> Do they mean the next one coming up?
> 
> Or do they mean that there's "this Saturday" coming up and "next
> Saturday" the one after that?
> 
> And if I can't figure it out, why would you expect PHP to figure it out?
> 
> :-)
> 
> On Thu, January 31, 2008 10:27 am, Mike Morton wrote:
>> Ya - the other server is 4.4.7
>> 
>> However - this does not seem to be the problem necessarily:
>> 
>> print date("m/d/Y",strtotime("next saturday"));
>> 02/09/2008
>> 
>> print date("m/d/Y",strtotime("next sunday"));
>> 02/10/2008
>> 
>> print date("m/d/Y",strtotime("next monday"));
>> 02/11/2008
>> 
>> print date("m/d/Y",strtotime("next tuesday"));
>> 02/12/2008
>> 
>> print date("m/d/Y",strtotime("next wednesday"));
>> 02/13/2008
>> 
>> print date("m/d/Y",strtotime("next thursday"));
>> 02/07/2008
>> 
>> So from today to next Thursday, the dates are all 1 week off?
>> 
>> On 1/31/08 11:03 AM, "Tom Chubb" <[EMAIL PROTECTED]> wrote:
>> 
>>> On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote:
 
 I have been using:
 
 $nextSaturday= date("m/d/Y",strtotime("next saturday"));
 
 For months long time now with out problems, but in the last two
 days, it
 went kind of funky.  It is now returning:
 
 02/09/2008 instead of the expected 02/02/2008.  I have tried the
 same code
 on another server and different version of PHP,and it works ok.
 
 More info:
 
 Shell date: Thu Jan 31 09:44:50 EST 2008
 echo date("Y-m-d g:i A T", time()); = 2008-01-31 10:00 AM EST
 echo date("Y-m-d g:i A T", strtotime("next saturday")); =
 2008-02-09 12:00
 AM EST
 
 version: 4.3.9  (highest version we can have at the moment)
 
 I could not find this in the known bugs from this version
 
 So - is this something that is server or version specific?
 
 TIA!
 
 --
 Cheers
 
 Mike Morton
 
 
 *
 * Tel: 905-465-1263
 * Email: [EMAIL PROTECTED]
 *
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
>>> The manual says:
>>> *Warning*
>>> 
>>> In PHP versions prior to 4.4.0, *"next"* is incorrectly computed as
>>> +2. A
>>> typical solution to this is to use *"+1"*.
>>> 
>>> Dunno if that helps you out? Is the other server > 4.4.0?
>>> http://uk3.php.net/strtotime
>> 
>> --
>> Cheers
>> 
>> Mike Morton
>> 
>> 
>> *
>> * Tel: 905-465-1263
>> * Email: [EMAIL PROTECTED]
>> *
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> 

-- 
Cheers

Mike Morton


*
* Tel: 905-465-1263
* Email: [EMAIL PROTECTED]
*


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....

2008-01-31 Thread Richard Lynch
Maybe it's just me, but I've never quite figured out what people mean
when they say "next Saturday"...

Do they mean the next one coming up?

Or do they mean that there's "this Saturday" coming up and "next
Saturday" the one after that?

And if I can't figure it out, why would you expect PHP to figure it out?

:-)

On Thu, January 31, 2008 10:27 am, Mike Morton wrote:
> Ya - the other server is 4.4.7
>
> However - this does not seem to be the problem necessarily:
>
> print date("m/d/Y",strtotime("next saturday"));
> 02/09/2008
>
> print date("m/d/Y",strtotime("next sunday"));
> 02/10/2008
>
> print date("m/d/Y",strtotime("next monday"));
> 02/11/2008
>
> print date("m/d/Y",strtotime("next tuesday"));
> 02/12/2008
>
> print date("m/d/Y",strtotime("next wednesday"));
> 02/13/2008
>
> print date("m/d/Y",strtotime("next thursday"));
> 02/07/2008
>
> So from today to next Thursday, the dates are all 1 week off?
>
> On 1/31/08 11:03 AM, "Tom Chubb" <[EMAIL PROTECTED]> wrote:
>
>> On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote:
>>>
>>> I have been using:
>>>
>>> $nextSaturday= date("m/d/Y",strtotime("next saturday"));
>>>
>>> For months long time now with out problems, but in the last two
>>> days, it
>>> went kind of funky.  It is now returning:
>>>
>>> 02/09/2008 instead of the expected 02/02/2008.  I have tried the
>>> same code
>>> on another server and different version of PHP,and it works ok.
>>>
>>> More info:
>>>
>>> Shell date: Thu Jan 31 09:44:50 EST 2008
>>> echo date("Y-m-d g:i A T", time()); = 2008-01-31 10:00 AM EST
>>> echo date("Y-m-d g:i A T", strtotime("next saturday")); =
>>> 2008-02-09 12:00
>>> AM EST
>>>
>>> version: 4.3.9  (highest version we can have at the moment)
>>>
>>> I could not find this in the known bugs from this version
>>>
>>> So - is this something that is server or version specific?
>>>
>>> TIA!
>>>
>>> --
>>> Cheers
>>>
>>> Mike Morton
>>>
>>> 
>>> *
>>> * Tel: 905-465-1263
>>> * Email: [EMAIL PROTECTED]
>>> *
>>> 
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> The manual says:
>> *Warning*
>>
>> In PHP versions prior to 4.4.0, *"next"* is incorrectly computed as
>> +2. A
>> typical solution to this is to use *"+1"*.
>>
>> Dunno if that helps you out? Is the other server > 4.4.0?
>> http://uk3.php.net/strtotime
>
> --
> Cheers
>
> Mike Morton
>
> 
> *
> * Tel: 905-465-1263
> * Email: [EMAIL PROTECTED]
> *
> 
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....

2008-01-31 Thread Tom Chubb
On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote:
>
> Ya - the other server is 4.4.7
>
> However - this does not seem to be the problem necessarily:
>
> print date("m/d/Y",strtotime("next saturday"));
> 02/09/2008
>
> print date("m/d/Y",strtotime("next sunday"));
> 02/10/2008
>
> print date("m/d/Y",strtotime("next monday"));
> 02/11/2008
>
> print date("m/d/Y",strtotime("next tuesday"));
> 02/12/2008
>
> print date("m/d/Y",strtotime("next wednesday"));
> 02/13/2008
>
> print date("m/d/Y",strtotime("next thursday"));
> 02/07/2008
>
> So from today to next Thursday, the dates are all 1 week off?
>
> On 1/31/08 11:03 AM, "Tom Chubb" <[EMAIL PROTECTED]> wrote:
>
> > On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote:
> >>
> >> I have been using:
> >>
> >> $nextSaturday= date("m/d/Y",strtotime("next saturday"));
> >>
> >> For months long time now with out problems, but in the last two days,
> it
> >> went kind of funky.  It is now returning:
> >>
> >> 02/09/2008 instead of the expected 02/02/2008.  I have tried the same
> code
> >> on another server and different version of PHP,and it works ok.
> >>
> >> More info:
> >>
> >> Shell date: Thu Jan 31 09:44:50 EST 2008
> >> echo date("Y-m-d g:i A T", time()); = 2008-01-31 10:00 AM EST
> >> echo date("Y-m-d g:i A T", strtotime("next saturday")); = 2008-02-09
> 12:00
> >> AM EST
> >>
> >> version: 4.3.9  (highest version we can have at the moment)
> >>
> >> I could not find this in the known bugs from this version
> >>
> >> So - is this something that is server or version specific?
> >>
> >> TIA!
> >>
> >> --
> >> Cheers
> >>
> >> Mike Morton
> >>
> >> 
> >> *
> >> * Tel: 905-465-1263
> >> * Email: [EMAIL PROTECTED]
> >> *
> >> 
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> > The manual says:
> > *Warning*
> >
> > In PHP versions prior to 4.4.0, *"next"* is incorrectly computed as +2.
> A
> > typical solution to this is to use *"+1"*.
> >
> > Dunno if that helps you out? Is the other server > 4.4.0?
> > http://uk3.php.net/strtotime
>
> --
> Cheers
>
> Mike Morton
>
> 
> *
> * Tel: 905-465-1263
> * Email: [EMAIL PROTECTED]
> *
> 
>
>
>
> An example that may help:

when using strtotime("wednesday"), you will get different results whether
you ask before or after wednesday, since strtotime always looks ahead to the
*next* weekday.

strtotime() does not seem to support forms like "this wednesday", "wednesday
this week", etc.

the following function addresses this by always returns the same specific
weekday (1st argument) within the *same* week as a particular date (2nd
argument).

function weekday($day="", $now="") {

  $now = $now ? $now : "now";
  $day = $day ? $day : "now";

  $rel = date("N", strtotime($day)) - date("N");

  $time = strtotime("$rel days", strtotime($now));

  return date("Y-m-d", $time);

}

example use:

weekday("wednesday"); // returns wednesday of this week
weekday("monday, "-1 week"); // return monday the in previous week

ps! the ? : statements are included because strtotime("") without gives 1
january 1970 rather than the current time which in my opinion would be more
intuitive...


Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....

2008-01-31 Thread Mike Morton
Ya - the other server is 4.4.7

However - this does not seem to be the problem necessarily:

print date("m/d/Y",strtotime("next saturday"));
02/09/2008

print date("m/d/Y",strtotime("next sunday"));
02/10/2008

print date("m/d/Y",strtotime("next monday"));
02/11/2008

print date("m/d/Y",strtotime("next tuesday"));
02/12/2008

print date("m/d/Y",strtotime("next wednesday"));
02/13/2008

print date("m/d/Y",strtotime("next thursday"));
02/07/2008

So from today to next Thursday, the dates are all 1 week off?

On 1/31/08 11:03 AM, "Tom Chubb" <[EMAIL PROTECTED]> wrote:

> On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote:
>> 
>> I have been using:
>> 
>> $nextSaturday= date("m/d/Y",strtotime("next saturday"));
>> 
>> For months long time now with out problems, but in the last two days, it
>> went kind of funky.  It is now returning:
>> 
>> 02/09/2008 instead of the expected 02/02/2008.  I have tried the same code
>> on another server and different version of PHP,and it works ok.
>> 
>> More info:
>> 
>> Shell date: Thu Jan 31 09:44:50 EST 2008
>> echo date("Y-m-d g:i A T", time()); = 2008-01-31 10:00 AM EST
>> echo date("Y-m-d g:i A T", strtotime("next saturday")); = 2008-02-09 12:00
>> AM EST
>> 
>> version: 4.3.9  (highest version we can have at the moment)
>> 
>> I could not find this in the known bugs from this version
>> 
>> So - is this something that is server or version specific?
>> 
>> TIA!
>> 
>> --
>> Cheers
>> 
>> Mike Morton
>> 
>> 
>> *
>> * Tel: 905-465-1263
>> * Email: [EMAIL PROTECTED]
>> *
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> The manual says:
> *Warning*
> 
> In PHP versions prior to 4.4.0, *"next"* is incorrectly computed as +2. A
> typical solution to this is to use *"+1"*.
> 
> Dunno if that helps you out? Is the other server > 4.4.0?
> http://uk3.php.net/strtotime

-- 
Cheers

Mike Morton


*
* Tel: 905-465-1263
* Email: [EMAIL PROTECTED]
*


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Strtotime returns 02/09/2008 for "next Saturday"....

2008-01-31 Thread Tom Chubb
On 31/01/2008, Mike Morton <[EMAIL PROTECTED]> wrote:
>
> I have been using:
>
> $nextSaturday= date("m/d/Y",strtotime("next saturday"));
>
> For months long time now with out problems, but in the last two days, it
> went kind of funky.  It is now returning:
>
> 02/09/2008 instead of the expected 02/02/2008.  I have tried the same code
> on another server and different version of PHP,and it works ok.
>
> More info:
>
> Shell date: Thu Jan 31 09:44:50 EST 2008
> echo date("Y-m-d g:i A T", time()); = 2008-01-31 10:00 AM EST
> echo date("Y-m-d g:i A T", strtotime("next saturday")); = 2008-02-09 12:00
> AM EST
>
> version: 4.3.9  (highest version we can have at the moment)
>
> I could not find this in the known bugs from this version
>
> So - is this something that is server or version specific?
>
> TIA!
>
> --
> Cheers
>
> Mike Morton
>
> 
> *
> * Tel: 905-465-1263
> * Email: [EMAIL PROTECTED]
> *
> 
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
The manual says: *Warning*

In PHP versions prior to 4.4.0, *"next"* is incorrectly computed as +2. A
typical solution to this is to use *"+1"*.

Dunno if that helps you out? Is the other server > 4.4.0?
http://uk3.php.net/strtotime


Re: [PHP] strtotime returns 00:00 for 7am

2007-06-21 Thread Greg Donald

On 6/20/07, Phil Princely <[EMAIL PROTECTED]> wrote:

using this code:

function test_time($time_string) {
echo strftime("%X %A, %b %e\n", strtotime($time_string));


You should be testing the strtotime() call's return value, it returns
false on failure.

if (($timestamp = strtotime($str)) === false) {}


}

test_time('now');
test_time('4pm + 2 Hours');
test_time('now + 2 fortnights');
test_time('last Monday');
test_time('tomorrow');
test_time('5am tomorrow');
test_time('7am 12 days ago');

gives this output:

21:46:18 Wednesday, Jun 20

18:00:00 Wednesday, Jun 20

21:46:18 Wednesday, Jul 18

00:00:00 Monday, Jun 18

00:00:00 Thursday, Jun 21

00:00:00 Thursday, Jun 21

07:00:00 Friday, Jun  8


I'm wondering why the 2nd and 3rd last both give 00:00 as the
time. Especially why 5am tomorrow doesn't work. Using PHP5.


That false return value I mentioned above becomes a zero when used as
the second parameter to strftime().


--
Greg Donald
http://destiney.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2006-10-25 Thread Google Kreme

On 24 Oct 2006, at 19:07 , Brad Chow wrote:

$date=("2006-10-26");
$date=strtotime($date);
$date=date('Y-m-1',$date);
$now=strtotime("+3 month", strtotime($date));
$lastday=strtotime("-1 day", $now);
echo date('Y-m-d',$lastday);
//2006-12-31


Yep, that's pretty much exactly what I do.  I suspect there is a much  
shorter, and more opaque but elegantly clever way of doing it, but  
that basic methodology has been with me since the mid 80's :)



--
One by one the bulbs burned out, like long lives come to their  
expected ends.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2006-10-25 Thread clive

Ron Piggott (PHP) wrote:

I have used the strtotime command to calculate a week ago (among other
things) with syntax like this:

$one_week_ago = strtotime("-7 days");
$one_week_ago = date('Y-m-d', $one_week_ago);

How would you use this command to figure out the last day of the month
in two months from now --- Today is October 24th 2006; the results I am
trying to generate are December 31st 2006.  I want to keep the same
result until the end of October and then on November 1st and throughout
November the result to be January 31st 2007

Ron
  

my suggestion:

$thefuturedate = mktime(0, 0, 0, date("m") + 3, 0,  date("Y"));

--
Regards,

Clive

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime

2006-10-24 Thread Brad Chow

Dear Ron:

I have a solution as follows:

$date=("2006-10-26");
$date=strtotime($date);
$date=date('Y-m-1',$date);
$now=strtotime("+3 month", strtotime($date));
$lastday=strtotime("-1 day", $now);
echo date('Y-m-d',$lastday);
//2006-12-31

It's a very easy way to do you want.
I use strtotime to convert date to the first day of this month.
And, add 3 months to the day and subtract 1 day.
Then, you can get the day you want.

Regads,


Brad

On 10/25/06, Ron Piggott (PHP) <[EMAIL PROTECTED]> wrote:



I have used the strtotime command to calculate a week ago (among other
things) with syntax like this:

$one_week_ago = strtotime("-7 days");
$one_week_ago = date('Y-m-d', $one_week_ago);

How would you use this command to figure out the last day of the month
in two months from now --- Today is October 24th 2006; the results I am
trying to generate are December 31st 2006.  I want to keep the same
result until the end of October and then on November 1st and throughout
November the result to be January 31st 2007

Ron




Re: [PHP] strtotime

2006-10-24 Thread Chris

Ron Piggott (PHP) wrote:

I have used the strtotime command to calculate a week ago (among other
things) with syntax like this:

$one_week_ago = strtotime("-7 days");
$one_week_ago = date('Y-m-d', $one_week_ago);

How would you use this command to figure out the last day of the month
in two months from now --- Today is October 24th 2006; the results I am
trying to generate are December 31st 2006.  I want to keep the same
result until the end of October and then on November 1st and throughout
November the result to be January 31st 2007


Not great but you could do:

$two_months = strtotime("+2 months");

// get the bits you need for mktime
$num_of_days = date('t', $two_months);
$month = date('n', $two_months);
$year = date('Y', $two_months);

$last_day = mktime(0, 0, 1, $month, $num_of_days, $year);

echo 'date: ' . date('r', $last_day);

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime('yesterday')

2005-05-25 Thread Burhan Khalid

Richard Lynch wrote:

On Tue, May 24, 2005 7:24 am, Rahul S. Johari said:


I¹m trying to delete all files in a folder based on a string match with
the
following code:

Erase Successful!All images up to $date, have been
permanently erased from the Server.";
?>

I need the code to delete all images created till yesterday, and leave
images created today. Somehow strtotime(Œyesterday¹) doesn¹t work.
If I put strtotime(Œ-2 days¹) or strtotime(Œ-7 days¹) or even
strtotime(Œ8:00am¹)... They all work accordingly. How come (Œyesterday¹)
isn¹t working? It doesn¹t delete anything.


[EMAIL PROTECTED] burhan $ php -r "echo date('r',strtotime('-1 day'));"
Tue, 24 May 2005 09:00:35 +0300

[EMAIL PROTECTED] burhan $ date
Wed May 25 09:02:10 AST 2005

:)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime('yesterday')

2005-05-24 Thread Richard Lynch
On Tue, May 24, 2005 7:24 am, Rahul S. Johari said:
> I¹m trying to delete all files in a folder based on a string match with
> the
> following code:
>
>  $dir = '/Library/WebServer/Documents/something.com/subfolder/';
> $dp = opendir($dir) or die ('Fatal Error: '.mysql_error());
> while ($file = readdir($dp)) {
> if ((eregi('.png',$file)) && (filemtime($dir.$file)) <
> (strtotime('yesterday'))) {
> unlink($dir.$file);
> }
> }
> closedir($dp);
> $yesterday = mktime( 0, 0, 0, date("m") , date("d")-1, date("Y") );
> $date = date( "m-d-y, D", $yesterday );
> echo "Erase Successful!All images up to $date, have been
> permanently erased from the Server.";
> ?>
>
> I need the code to delete all images created till yesterday, and leave
> images created today. Somehow strtotime(Œyesterday¹) doesn¹t work.
> If I put strtotime(Œ-2 days¹) or strtotime(Œ-7 days¹) or even
> strtotime(Œ8:00am¹)... They all work accordingly. How come (Œyesterday¹)
> isn¹t working? It doesn¹t delete anything.

Maybe strtotime('-1 day') would work. [shrug]

You could also use http://php.net/mktime

mktime(date('m'), -1); //This should be 24 hours before 'now', I think...

Or maybe mktime(date('m'), date('d) -1);

Whichever it is, PHP's mktime does the right thing even if you use, like:
mktime(6, 0); //This is really May 31st, not June 0. PHP knows.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime() lost precision?

2005-04-26 Thread Jochem Maas
Mario de Frutos Dieguez wrote:
Hi!
I'm back hahaha :D
I'm making functions to calculate the duration (only laboral days) 
between 2 dates and the initial and final date between a duration give 
me in laboral days.

I use the following function to make the diference between 2 dates:
function fecDiferenciaFechas($fecFechaInicio,$fecFechaFin)
   {
   $fecFechaInicio=strtotime($fecFechaInicio);
   $fecFechaFin=strtotime($fecFechaFin);
 if ($fecFechaFin == -1 || $fecFechaInicio == -1)
   {
   return false;
   }
 $iDiferencia = $fecFechaFin - $fecFechaInicio;
 //Inicializamos la variable
   $iDias = 0;
 //Devolvemos la diferencia en dias
   return ($iDiferencia/86400);
   }
The problem is that with a duration of 220 the return is 219.958333, 
where im losing precision?
computers can't stores floats precisely, precision errors are. Rasmus gave 
a good explaination
of this on this list not so long ago - that said there is lots of info on this 
on the web,
here is one good article to get you started:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
on a more practical note take a look at the following php functions:
round(), ceil(), floor()
one of those should provide you with a 'fix' to the precision error(s) you are
seeing.
(Sorry for my home english :P)
Don't worry about it! my spanish begins and ends at 'Hasta la vista' ;-)
actually that's not strictly true - I managed to have a whole conversation
in Spanish once only using the word 'bale' (I think there is supposed to be an 
accent on
the 'e' of 'bale')
(btw. I couldn't quite figure out what 'home english' is)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] strtotime() bug?

2005-04-05 Thread Richard Lynch
On Mon, April 4, 2005 3:14 pm, Al said:
> Suddenly my strtotime() are goofy, anyone have any ideas?
>
> echo date('Y/m/d/H', time()). ""; //2005/04/04/18
> echo date('Y/m/d/H', strtotime("-1 day")). "";
> //2005/04/03/18
> echo date('Y/m/d/H', strtotime("last Sunday")). "";   
> //2005/04/02/23
>
> Sunday shows as Saturday.

If the BIOS thinks you don't use Daylight Savings, but the OS thinks you
*DO* use Daylight Savings, but Locale thinks you don't use Daylight
Savings, but...

Or any variation on that theme.

This is just theory of what could be going wrong, without my delving too
deeply into what you typed...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strtotime time zone trouble

2005-01-18 Thread Michael Sims
Marcus Bointon wrote:
> Much of the point of using zone names rather than fixed numeric
> offsets is that it allows for correct daylight savings calculations
> (assuming that locale data is correct on the server).
>
> Let me rephrase the question - how can I get the current time in a
> named time zone using strtotime and without using a numeric offset?

This may not be the cleanest way to approach it, but this is what I use and it 
Works
For Me(TM):

$timeZoneMap = array(
  'EST5EDT' => 'Eastern Time',
  'CST6CDT' => 'Central Time',
  'MST7MDT' => 'Mountain Time',
  'PST8PDT' => 'Pacific Time'
);

$currentTime = time();
foreach ($timeZoneMap as $envVar => $timeZone) {
  putenv("TZ=$envVar");
  print "The current time in $timeZone is ";
  print strftime('%m/%d/%Y %I:%M:%S %p %Z', $currentTime)."\n";
}

HTH

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime time zone trouble

2005-01-18 Thread M. Sokolewicz
Tom wrote:
Marcus Bointon wrote:
On 18 Jan 2005, at 10:53, Tom wrote:
PST = UTC - 8, therefore if you ask for strtotime in PST it will give 
you  now + 8. This is standard in most languages, you are just 
reading the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the 
current local time (UTC in your instance) given an input date in PST

OK, I see some logic in that - now how to work around it?
try
print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";

sorry, wrong language, you need
echo "full date PST is ", date('Y-m-d H:i:s', strtotime('now -8 
hours')), "";
If you define the constants in another file, then you can use them wherever
eg $PST = -8;
I do hope you mean variable and not constant here...
...
$dateString = 'now '.$PST.' hours';
echo "full date PST is ", date('Y-m-d H:i:s', strtotime($dateString)), 
"";

Tom
That definitely won't work; -0800 will be interpreted as an octal 
value, but it's not a legal value. If it was interpreted as a decimal 
value, it would subtract 800 minutes, which is no use to anyone. 
Numeric offsets are supposed to work inside the strtotime string 
param, according to the docs.

Much of the point of using zone names rather than fixed numeric 
offsets is that it allows for correct daylight savings calculations 
(assuming that locale data is correct on the server).

Let me rephrase the question - how can I get the current time in a 
named time zone using strtotime and without using a numeric offset?

Marcus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] strtotime time zone trouble

2005-01-18 Thread M. Sokolewicz
Marcus Bointon wrote:
On 18 Jan 2005, at 10:53, Tom wrote:
PST = UTC - 8, therefore if you ask for strtotime in PST it will give 
you  now + 8. This is standard in most languages, you are just reading 
the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the 
current local time (UTC in your instance) given an input date in PST

OK, I see some logic in that - now how to work around it?
try
print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";

That definitely won't work; -0800 will be interpreted as an octal value, 
but it's not a legal value. If it was interpreted as a decimal value, it 
would subtract 800 minutes, which is no use to anyone.
actually, it would be 800 seconds (in octal, which is a non-existent 
number (like saying A in decimal, or 2 in binary)).

 Numeric offsets
are supposed to work inside the strtotime string param, according to the 
docs.

Much of the point of using zone names rather than fixed numeric offsets 
is that it allows for correct daylight savings calculations (assuming 
that locale data is correct on the server).

Let me rephrase the question - how can I get the current time in a named 
time zone using strtotime and without using a numeric offset?

Marcus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] strtotime time zone trouble

2005-01-18 Thread Tom
Marcus Bointon wrote:
On 18 Jan 2005, at 10:53, Tom wrote:
PST = UTC - 8, therefore if you ask for strtotime in PST it will give 
you  now + 8. This is standard in most languages, you are just 
reading the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the 
current local time (UTC in your instance) given an input date in PST

OK, I see some logic in that - now how to work around it?
try
print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";

sorry, wrong language, you need
echo "full date PST is ", date('Y-m-d H:i:s', strtotime('now -8 
hours')), "";
If you define the constants in another file, then you can use them wherever
eg $PST = -8;
...
$dateString = 'now '.$PST.' hours';
echo "full date PST is ", date('Y-m-d H:i:s', strtotime($dateString)), 
"";

Tom
That definitely won't work; -0800 will be interpreted as an octal 
value, but it's not a legal value. If it was interpreted as a decimal 
value, it would subtract 800 minutes, which is no use to anyone. 
Numeric offsets are supposed to work inside the strtotime string 
param, according to the docs.

Much of the point of using zone names rather than fixed numeric 
offsets is that it allows for correct daylight savings calculations 
(assuming that locale data is correct on the server).

Let me rephrase the question - how can I get the current time in a 
named time zone using strtotime and without using a numeric offset?

Marcus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] strtotime time zone trouble

2005-01-18 Thread Marcus Bointon
On 18 Jan 2005, at 10:53, Tom wrote:
PST = UTC - 8, therefore if you ask for strtotime in PST it will give 
you  now + 8. This is standard in most languages, you are just reading 
the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the 
current local time (UTC in your instance) given an input date in PST
OK, I see some logic in that - now how to work around it?
try
print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";
That definitely won't work; -0800 will be interpreted as an octal 
value, but it's not a legal value. If it was interpreted as a decimal 
value, it would subtract 800 minutes, which is no use to anyone. 
Numeric offsets are supposed to work inside the strtotime string param, 
according to the docs.

Much of the point of using zone names rather than fixed numeric offsets 
is that it allows for correct daylight savings calculations (assuming 
that locale data is correct on the server).

Let me rephrase the question - how can I get the current time in a 
named time zone using strtotime and without using a numeric offset?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] strtotime time zone trouble

2005-01-18 Thread Tom
Marcus Bointon wrote:
How is this not a bug?

outputs:
2005-01-18 09:58:09 (correct)
2005-01-18 17:58:09 (incorrect)
PST = UTC - 8, therefore if you ask for strtotime in PST it will give 
you  now + 8. This is standard in most languages, you are just reading 
the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the 
current local time (UTC in your instance) given an input date in PST

The time zone correction is applied in the wrong direction. Does it in 
both current PHP 4 and 5.

Named time zones like these are supposedly deprecated, but the 
suggested alternative in the docs doesn't work at all:

print date('Y-m-d H:i:s', strtotime('now UTC-0800'))."\n";
try
print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Strtotime() weirdness

2004-06-02 Thread Burhan Khalid
Alex Hogan wrote:
Does anybody know of any peculiarities in the strtotime() function?
 
If I enter any date before 1 Jan 1970 I get a -1 returned.
Note:  The valid range of a timestamp is typically from Fri, 13 Dec 1901 
20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that 
correspond to the minimum and maximum values for a 32-bit signed 
integer.) Additionally, not all platforms support negative timestamps, 
therefore your date range may be limited to no earlier than the Unix 
epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on 
Windows, some Linux distributions, and a few other operating systems.

http://www.php.net/strtotime
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Strtotime() weirdness

2004-06-01 Thread Daniel Clark
http://us3.php.net/manual/en/function.strtotime.php

Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901
20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that
correspond to the minimum and maximum values for a 32-bit signed integer.)
Additionally, not all platforms support negative timestamps, therefore
your date range may be limited to no earlier than the Unix epoch. This
means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some
Linux distributions, and a few other operating systems.


> Does anybody know of any peculiarities in the strtotime() function?
>
> If I enter any date before 1 Jan 1970 I get a -1 returned.
>
> alex hogan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime Question

2004-01-27 Thread - Edwin -
Hi,

On Tue, 27 Jan 2004 23:05:09 -0500
gohaku <[EMAIL PROTECTED]> wrote:

> Hi everyone,
> I made the mistake of using strtotime("day") instead of 
> strtotime("today")
> to get the current time.
> I was just curious, what is strtotime("day") represent?
> 
> Below is what I used to test the "day" and "today" parameters:
> 
> Testing One Minute Difference
>  echo min_diff();
> function min_diff()
> {
>   $now = strtotime("today");//Return value is 60
>   //$now = strtotime("day");//Return value is 86400
>   $onemin = strtotime("-1 minute");
>   return $now-$onemin;
> }
> ?>

60 seconds * 60 min. * 24 hrs. = 86400?

--

- E -
__
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime bad logic or strtotime bug?

2003-11-17 Thread Gnik
WOW! Blindingly simple mistake --> couldn't see the forest before the
trees (or something like that). THANKS for the helping hand! 

Gnik
--- Eugene Lee <[EMAIL PROTECTED]> wrote:
> On Fri, Nov 14, 2003 at 08:53:41PM -0800, Gnik wrote:
> : 
> : One of my servers required a PHP upgrade. Afterwards one of the PHP
> : projects stopped functioning. When it would run one section would
> : scroll endlessly. I can't figure out if it's a 'bug' or if it's bad
> : logic in the coding. 
> 
> Bad logic.  But it took me a while to figure it out.  I'm glad I did;
> I know it will save me countless headaches in the future!  :-)
> 
> : I isolated the problem to be in the 'strtotime' function. Here is a
> : test I ran - when it runs, after getting to 2003-10-26, it scrolls
> : incessently: 
> : 
> : BEGIN CODE--
> :  : echo "Testing strtotime ";
> : print " " ;
> : $stop= "2003-12-27" ;
> : $start= "2003-01-01" ;
> : While ($start <> $stop) {
> : echo " Date: " . $start ;
> : $start = date('Y-m-d', strtotime($start) + 86400);
> : }
> : ?>
> : END CODE--
> 
> It's a logic bug due to the wonderful world of Daylight Saving Time.
> When the clock strikes 2003-10-26, adding 86400 seconds to calculate the
> next day's timestamp is normally correct.  However, that date is also
> the last Sunday of Octobor when the U.S. officially reverts from
> Daylight Saving Time back to normal time.  Your next day's timestamp
> "loses" one hour, i.e. 3600 seconds; your timestamp for 2003-10-27 12am
> is now 2003-10-26 11pm.  Because your date() call extracts only the
> date,
> your truncation error is causing you to get stuck on 2003-10-26.  This
> is
> the cause of your infinite loop.
> 
> There are several ways to avoid this problem.  The easiest way to change
> date() to gmdate().  This gets you on UTC time, which is independent of
> Daylight Saving Time or your timezone.
> 
> Hope this helps!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime bad logic or strtotime bug?

2003-11-16 Thread Eugene Lee
On Fri, Nov 14, 2003 at 08:53:41PM -0800, Gnik wrote:
: 
: One of my servers required a PHP upgrade. Afterwards one of the PHP
: projects stopped functioning. When it would run one section would
: scroll endlessly. I can't figure out if it's a 'bug' or if it's bad
: logic in the coding. 

Bad logic.  But it took me a while to figure it out.  I'm glad I did;
I know it will save me countless headaches in the future!  :-)

: I isolated the problem to be in the 'strtotime' function. Here is a
: test I ran - when it runs, after getting to 2003-10-26, it scrolls
: incessently: 
: 
: BEGIN CODE--
: Testing strtotime ";
: print " " ;
: $stop= "2003-12-27" ;
: $start= "2003-01-01" ;
: While ($start <> $stop) {
: echo " Date: " . $start ;
: $start = date('Y-m-d', strtotime($start) + 86400);
: }
: ?>
: END CODE--

It's a logic bug due to the wonderful world of Daylight Saving Time.
When the clock strikes 2003-10-26, adding 86400 seconds to calculate the
next day's timestamp is normally correct.  However, that date is also
the last Sunday of Octobor when the U.S. officially reverts from
Daylight Saving Time back to normal time.  Your next day's timestamp
"loses" one hour, i.e. 3600 seconds; your timestamp for 2003-10-27 12am
is now 2003-10-26 11pm.  Because your date() call extracts only the date,
your truncation error is causing you to get stuck on 2003-10-26.  This is
the cause of your infinite loop.

There are several ways to avoid this problem.  The easiest way to change
date() to gmdate().  This gets you on UTC time, which is independent of
Daylight Saving Time or your timezone.

Hope this helps!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime bad logic or strtotime bug?

2003-11-15 Thread Chris Shiflett
--- Gnik <[EMAIL PROTECTED]> wrote:
> I isolated the problem to be in the 'strtotime' function. Here is a
> test I ran - when it runs, after getting to 2003-10-26, it scrolls
> incessently:
> 
> BEGIN CODE--
>  $stop= "2003-12-27" ;
> $start= "2003-01-01" ;
> While ($start <> $stop) {
> echo " Date: " . $start ;
> $start = date('Y-m-d', strtotime($start) + 86400);
> }
> ?>
> END CODE--

Your approach makes me wonder why you are bothering to convert between
timestamps and formatted dates so many times. It makes much more sense to
use timestamps for conditionals and math, and use date() only in your echo
statement.

As for your particular error, I'm sure you could easily find it with just
a few minutes of debugging. For example, output the value of $start and
$stop at the beginning and very end of each loop.

Also, you might want to use != for not equal. From the manual
(http://www.php.net/manual/en/language.expressions.php):

PHP supports > (bigger than), >= (bigger than or equal to), == (equal), !=
(not equal), < (smaller than) and <= (smaller than or equal to). These
expressions are most commonly used inside conditional execution, such as
if  statements.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2003-08-14 Thread Chris Boget
> > strtotime( '+1 month', mktime( 0, 0, 0, 1, 1, 2003 ));
> > I get back the timestamp for 1/31/2003 and not 2/1/2003.
> Are you sure?

Yeah, but I missed something in my above example.  If I did this:
 
strtotime( '+1 month GMT', mktime( 0, 0, 0, 1, 1, 2003 ));

It came back with 1/31/2003 and not 2/1/2003.  Removing the GMT
made it work. Your example works as well.   In any case, the whole 
reason I'm delving into this is because strtotime() is exhibiting some 
odd behavior.  Consider the following:
(Note: you can see the values of all the variables in the output below)

echo 'StatementDueDate: ' . 
   $tmpPremiumArray[($curLayoutArray['Settlement Due Date'])] . ' -- ' . 
   date( "Y-m-{$settlement_day_due} H:i:s", 
$tmpPremiumArray[($curLayoutArray['Settlement Due Date'])] ) . 
   '';

$tmpSettlementDate = strtotime( '+1 month', 
   $tmpPremiumArray[($curLayoutArray['Settlement Due Date'])] );

echo "tmpSettlementDate: $tmpSettlementDate -- " . 
   date( 'Y-m-d H:i:s', $tmpSettlementDate ) . "\n";

Yelds the following output

StatementDueDate: 1053360326 -- 2003-05-20 11:05:26
tmpSettlementDate: 1056038726 -- 2003-06-19 11:05:26

As you can see here, strtotime( '+1 month' ) is adding only 30 days.  I
am at a total loss to explain why this is the case, especially in light of
the working example you provided.

Chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2003-08-14 Thread Rob Adams

"Jennifer Goodie" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > > > strtotime( '+1 month', mktime( 0, 0, 0, 1, 1, 2003 ));
> > > > I get back the timestamp for 1/31/2003 and not 2/1/2003.
> > > Are you sure?
> >
> > Yeah, but I missed something in my above example.  If I did this:
> >
> > strtotime( '+1 month GMT', mktime( 0, 0, 0, 1, 1, 2003 ));
> >
> > It came back with 1/31/2003 and not 2/1/2003.  Removing the GMT
> > made it work.
>
> Are you somewhere behind GMT?  I get an hour shift when using GMT that
puts
> me in the previous day.  I'm GMT -8.  I can't think right now, but for
some
> reason it seems like it's shifting in the wrong direction or at least the
> opposite of what I'd expect.  I guess it is subtracting my 8 hours and
then
> shifting, making it 16:00 of the previous day.  It seems like it should
add
> 8 hours since GMT is 8 ahead of me.  This is making my head hurt, maybe
> someone else can make it make sense.
>
> # php
>  $ts = mktime( 0, 0, 0, 1, 1, 2003 );
> echo date ("Y-m-d H:i:s",$ts)."\n";
> $ts2 = strtotime('+1 month GMT', $ts);
> echo date ("Y-m-d H:i:s",$ts2)."\n";
> $ts3 = strtotime('+1 month', $ts);
> echo date ("Y-m-d H:i:s",$ts3)."\n";
> ?>
> X-Powered-By: PHP/4.2.3
> Content-type: text/html
>
> 2003-01-01 00:00:00
> 2003-01-31 16:00:00
> 2003-02-01 00:00:00
>

It is adjusting for your 8 hour differences.

Your server is -8 from GMT.
So when you set it to '+ 1 month GMT' it will set the date to one month from
the given date, but in GMT time.  So to convert back from GMT time to your
time, it needs to minus the 8 hours, and you get 4 PM the day before.

  -- Rob



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime()

2003-08-14 Thread Marek Kilimajer
My feeling is you should use gmmktime() if you use GMT in strtotime()

Chris Boget wrote:
Yeah, but I missed something in my above example.  If I did this:
 
strtotime( '+1 month GMT', mktime( 0, 0, 0, 1, 1, 2003 ));

It came back with 1/31/2003 and not 2/1/2003.  Removing the GMT
made it work. Your example works as well.   In any case, the whole 
reason I'm delving into this is because strtotime() is exhibiting some 
odd behavior.  Consider the following:
(Note: you can see the values of all the variables in the output below)




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] strtotime()

2003-08-14 Thread Jennifer Goodie
> strtotime( '+1 month', mktime( 0, 0, 0, 1, 1, 2003 ));
>
> I get back the timestamp for 1/31/2003 and not 2/1/2003.
>
Are you sure?

I tried it on my system (php 4.2.3 freeBSD 4.6.2) and this is the output I
got...
# php

X-Powered-By: PHP/4.2.3
Content-type: text/html

2003-01-01
2003-02-01

What are you doing with the timestamp strtotime gives you?  Could that be
where the error is?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] strtotime()

2003-08-14 Thread Jennifer Goodie
> > > strtotime( '+1 month', mktime( 0, 0, 0, 1, 1, 2003 ));
> > > I get back the timestamp for 1/31/2003 and not 2/1/2003.
> > Are you sure?
>
> Yeah, but I missed something in my above example.  If I did this:
>
> strtotime( '+1 month GMT', mktime( 0, 0, 0, 1, 1, 2003 ));
>
> It came back with 1/31/2003 and not 2/1/2003.  Removing the GMT
> made it work.

Are you somewhere behind GMT?  I get an hour shift when using GMT that puts
me in the previous day.  I'm GMT -8.  I can't think right now, but for some
reason it seems like it's shifting in the wrong direction or at least the
opposite of what I'd expect.  I guess it is subtracting my 8 hours and then
shifting, making it 16:00 of the previous day.  It seems like it should add
8 hours since GMT is 8 ahead of me.  This is making my head hurt, maybe
someone else can make it make sense.

# php

X-Powered-By: PHP/4.2.3
Content-type: text/html

2003-01-01 00:00:00
2003-01-31 16:00:00
2003-02-01 00:00:00


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strtotime bug? end of the month.

2002-10-31 Thread Jeff Bearer
Actually I only needed date("Y-m") so my solution works fine, and I
didn't consider the problems with hard coding 1 into it.  But thanks for
the replies.





On Thu, 2002-10-31 at 11:33, Jeff Bearer wrote:
> date("Y-m-d",strtotime("+1 month"))
> 
> returns December 1st!  This happens when you add 1 month to any day that
> doesn't exist in the next month.  Quite annoying that you have to handle
> it like this:
> 
> date("Y-m-d",strtotime("+1 month",strtotime(date("Y-m-1"
> 
> 
> -- 
> Jeff Bearer, RCHE
> Webmaster, PittsburghLIVE.com
> Winner 2002 Eppy Award, Best U.S. Newspaper Website
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
-- 
Jeff Bearer, RCHE
Webmaster, PittsburghLIVE.com
Winner 2002 Eppy Award, Best U.S. Newspaper Website


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] strtotime bug? end of the month.

2002-10-31 Thread Michael Hazelden
How about - and a little more complex ...

$mydate = date("d")!=1 && date("d",strtotime("+1 month"))==1 ?
date("Y-m-d",strtotime("+1 month")-86400) : date("Y-m-d",strtotime("+1
month"));

to summarise - if you perform your "+1 month" and it creates a day of 1, but
the current day isn't 1 - do the same calculation, but a day less ...
otherwise - do the month more. I haven't tested it - but it should give the
results you want.

-Original Message-
From: 1LT John W. Holmes [mailto:holmes072000@;charter.net]
Sent: 31 October 2002 17:10
To: Jeff Bearer; [EMAIL PROTECTED]
Subject: Re: [PHP] strtotime bug? end of the month.


> date("Y-m-d",strtotime("+1 month"))
> 
> returns December 1st!  This happens when you add 1 month to any day that
> doesn't exist in the next month.  Quite annoying that you have to handle
> it like this:
> 
> date("Y-m-d",strtotime("+1 month",strtotime(date("Y-m-1"

How about

echo date('y-m-d',strtotime('next month last day'));

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


_
This message has been checked for all known viruses by the 
MessageLabs Virus Control Centre.

This message has been checked for all known viruses by the MessageLabs Virus Control 
Centre.


*

Notice:  This email is confidential and may contain copyright material of Ocado 
Limited (the "Company"). Opinions and views expressed in this message may not 
necessarily reflect the opinions and views of the Company.
If you are not the intended recipient, please notify us immediately and delete all 
copies of this message. Please note that it is your responsibility to scan this 
message for viruses.

Company reg. no. 3875000.  Swallowdale Lane, Hemel Hempstead HP2 7PY

*

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime bug? end of the month.

2002-10-31 Thread 1LT John W. Holmes
> date("Y-m-d",strtotime("+1 month"))
> 
> returns December 1st!  This happens when you add 1 month to any day that
> doesn't exist in the next month.  Quite annoying that you have to handle
> it like this:
> 
> date("Y-m-d",strtotime("+1 month",strtotime(date("Y-m-1"

How about

echo date('y-m-d',strtotime('next month last day'));

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime bug? end of the month.

2002-10-31 Thread Adam Voigt
Not a very good solution, but +4 weeks works.

Adam Voigt
[EMAIL PROTECTED]

On Thu, 2002-10-31 at 11:33, Jeff Bearer wrote:
> date("Y-m-d",strtotime("+1 month"))
> 
> returns December 1st!  This happens when you add 1 month to any day that
> doesn't exist in the next month.  Quite annoying that you have to handle
> it like this:
> 
> date("Y-m-d",strtotime("+1 month",strtotime(date("Y-m-1"
> 
> 
> -- 
> Jeff Bearer, RCHE
> Webmaster, PittsburghLIVE.com
> Winner 2002 Eppy Award, Best U.S. Newspaper Website
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime problem

2002-02-04 Thread DL Neil

Torben,

> > > No offense, but in TFM (which you have of course R), follow the 'Date
> > > Input Formats' link to:
> > >
> > >http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html
> > >
> > > You will find this sentence:
> > >
> > >The construct 'month/day/year', popular in the United States, is
> > >accepted.
> > >
> > > In other words, '10/12/2002' should work fine with strtotime(). The
> > > problem is elsewhere.
> >
> >
> > =One thing for sure, I'm not going to get into an argument with the guy who may 
>well have written that very
part
> > of the manual !
>
> Well, I didn't write that bit--and being an author doesn't necessarily
> make me any more likely to be correct--just more publicly wrong when I
> screw up. :)

=ah the joys of leadership, and the "loneliness of command"!

=I have a healthy respect for the PHP manual - and thus, its authors. It is unusually 
complete (for an open
source product) and very readable.

=I also make extensive use of the PHP-ER.

> > =The -1 is the key indicator.
>
> Yeah, I forgot to mention to Toni why $date3 was so weird--feeding a
> string instead of a timestamp to date().
>
> > =Rather than majoring on the manual, I was working on Toni's email address (which 
>told me very little) and
the
> > fact that she is on the US Pacific Coast. In other words, her server time zone 
>(which affects the way data
> > functions work) is likely subject to Summer Time discontinuities. This combined 
>with the date being
converted
> > back and forth with datetime formats, crosses the from one day to the other.
>
> Yeah, that's what I figured too (being in Vancouver, I run into this
> problem every so often).


=and I've just realised that I wrote "US Pacific Coast" which will attract comments 
from Canucks like a
lightning rod - excuse: I'm 'talking' with a colleague in San Diego... (he's having 
his chocolate biscuit and
coffee for afternoon break - and I'm having something similar for a bedtime snack - 
here, have one yourself)


=We still don't know where Toni and/or her(?) server are actually located. I wait with 
bated breath...


=As someone who works with(in) international organisations and moving around (the 
world) frequently, I pay a lot
of attention to where I am, and what time it is - and have a glowering dislike of 
ignorami who phone me at 0400
(local) having decided that lunchtime their time must be a 'good time' or who 
miscalculated thinking that it was
actually 1600!

=This topic confuses the life out of 'normal' people - and the summer time changes 
producing discontinuities so
that one hour ago, may not in fact have 'happened' one hour previously, is a real 
mind-bender. Guess such people
should be prohibited from flying/sailing across the International Date Line!

=A few years ago, I considered working on Y2K projects to have brought me full circle 
(of the clock?) having
spent quite a bit of time early in my career writing time-date subroutines for newly 
acquired machines/operating
systems. Now I find myself back in a similar arena with PHP/MySQL.

=My recommended solution is always to refer everything to a 'constant' time. That is 
to say, not use local
summer time, or in the case of multiple time zones use UTC/Zulu (in PHP the gm* 
functions - as in GMT). I have a
standard 'lecture' on the subject, which has been thrown at various lists, from 
time-to-time. Last time I
reviewed it, I was trying to remember where I had read a really good write-up about 
the 'confusion of time', so
thanks for reminding me about the GNU docs reference (ex-PHP manual, strtotime() ), 
because that's where it is!

=Now if you could find me a similarly logical cure for 'jet lag'...

=Regards,
=dn



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime problem

2002-02-04 Thread Lars Torben Wilson

On Mon, 2002-02-04 at 15:05, DL Neil wrote:
> Torben,
> > No offense, but in TFM (which you have of course R), follow the 'Date
> > Input Formats' link to:
> >
> >http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html
> >
> > You will find this sentence:
> >
> >The construct 'month/day/year', popular in the United States, is
> >accepted.
> >
> > In other words, '10/12/2002' should work fine with strtotime(). The
> > problem is elsewhere.
> 
> 
> =One thing for sure, I'm not going to get into an argument with the guy who may well 
>have written that very part
> of the manual !

Well, I didn't write that bit--and being an author doesn't necessarily 
make me any more likely to be correct--just more publicly wrong when I
screw up. :)
 
> =The -1 is the key indicator.

Yeah, I forgot to mention to Toni why $date3 was so weird--feeding a 
string instead of a timestamp to date().

> =Rather than majoring on the manual, I was working on Toni's email address (which 
>told me very little) and the
> fact that she is on the US Pacific Coast. In other words, her server time zone 
>(which affects the way data
> functions work) is likely subject to Summer Time discontinuities. This combined with 
>the date being converted
> back and forth with datetime formats, crosses the from one day to the other.

Yeah, that's what I figured too (being in Vancouver, I run into this
problem every so often).


Cheers,

Torben
 
> =Regards,
> =dn
> 
-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime problem

2002-02-04 Thread DL Neil

Torben,

> > toni,
> >
> > > $date1 = "10/12/2002";
> > > $date1 = date("D M j Y", strtotime($date1));
> > > $date2 = date("D M j Y");
> > > $date3 = date("D M j Y", $date1);
> > > print $date1."";
> > > print $date2."";
> > > print $date3."";
> > >
> > > The code above gives me the following output:
> > >
> > > Fri Oct 11 2002
> > > Mon Feb 4 2002
> > > Wed Dec 31 1969
> > >
> > > Is the strtotime() function causing this problem?
> >
> >
> > =yes, in a way. Please RTFM:
> > strtotime -- Parse about any English textual datetime description into a UNIX 
>timestamp
> >
> > The function expects to be given a string containing an English date
> >  format and will try to parse that format into a UNIX timestamp relative
> >  to the timestamp given in now, or the current time
> >  if none is supplied. Upon failure, -1 is returned.
> >
> > =The -1 explains $date3, it also enables you to back-track to an issue with $date1.
> >
> > =If you are in America, what does 10/12 mean?
> > =If you are in Europe, what does 10/12 mean?
> > =Thus, how can strtotime() attempt to determine the meaning of the textual date?
> > (I'll send you the full lecture if you have no idea what I'm talking about)
>
> No offense, but in TFM (which you have of course R), follow the 'Date
> Input Formats' link to:
>
>http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html
>
> You will find this sentence:
>
>The construct 'month/day/year', popular in the United States, is
>accepted.
>
> In other words, '10/12/2002' should work fine with strtotime(). The
> problem is elsewhere.


=One thing for sure, I'm not going to get into an argument with the guy who may well 
have written that very part
of the manual !

=The -1 is the key indicator.

=Rather than majoring on the manual, I was working on Toni's email address (which told 
me very little) and the
fact that she is on the US Pacific Coast. In other words, her server time zone (which 
affects the way data
functions work) is likely subject to Summer Time discontinuities. This combined with 
the date being converted
back and forth with datetime formats, crosses the from one day to the other.

=Regards,
=dn


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime problem

2002-02-04 Thread Lars Torben Wilson

On Tue, 2002-02-05 at 14:11, DL Neil wrote:
> toni,
> 
> > $date1 = "10/12/2002";
> > $date1 = date("D M j Y", strtotime($date1));
> > $date2 = date("D M j Y");
> > $date3 = date("D M j Y", $date1);
> > print $date1."";
> > print $date2."";
> > print $date3."";
> > 
> > The code above gives me the following output:
> > 
> > Fri Oct 11 2002
> > Mon Feb 4 2002
> > Wed Dec 31 1969
> > 
> > Is the strtotime() function causing this problem?
> 
> 
> =yes, in a way. Please RTFM:
> strtotime -- Parse about any English textual datetime description into a UNIX 
>timestamp
>
> The function expects to be given a string containing an English date
>  format and will try to parse that format into a UNIX timestamp relative
>  to the timestamp given in now, or the current time
>  if none is supplied. Upon failure, -1 is returned.
> 
> =The -1 explains $date3, it also enables you to back-track to an issue with $date1. 
> 
> =If you are in America, what does 10/12 mean?
> =If you are in Europe, what does 10/12 mean?
> =Thus, how can strtotime() attempt to determine the meaning of the textual date? 
> (I'll send you the full lecture if you have no idea what I'm talking about)

No offense, but in TFM (which you have of course R), follow the 'Date 
Input Formats' link to:

   http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html

You will find this sentence:

   The construct 'month/day/year', popular in the United States, is
   accepted. 

In other words, '10/12/2002' should work fine with strtotime(). The
problem is elsewhere.


Torben

> =Regards,
> =dn
 
-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime problem

2002-02-04 Thread DL Neil

toni,

> $date1 = "10/12/2002";
> $date1 = date("D M j Y", strtotime($date1));
> $date2 = date("D M j Y");
> $date3 = date("D M j Y", $date1);
> print $date1."";
> print $date2."";
> print $date3."";
> 
> The code above gives me the following output:
> 
> Fri Oct 11 2002
> Mon Feb 4 2002
> Wed Dec 31 1969
> 
> Is the strtotime() function causing this problem?


=yes, in a way. Please RTFM:
strtotime -- Parse about any English textual datetime description into a UNIX timestamp
   
The function expects to be given a string containing an English date
 format and will try to parse that format into a UNIX timestamp relative
 to the timestamp given in now, or the current time
 if none is supplied. Upon failure, -1 is returned.

=The -1 explains $date3, it also enables you to back-track to an issue with $date1. 

=If you are in America, what does 10/12 mean?
=If you are in Europe, what does 10/12 mean?
=Thus, how can strtotime() attempt to determine the meaning of the textual date? 
(I'll send you the full lecture if you have no idea what I'm talking about)

=Regards,
=dn



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime problem

2002-02-04 Thread Lars Torben Wilson

On Mon, 2002-02-04 at 13:40, toni baker wrote:
> $date1 = "10/12/2002";
> $date1 = date("D M j Y", strtotime($date1));
> $date2 = date("D M j Y");
> $date3 = date("D M j Y", $date1);
> print $date1."";
> print $date2."";
> print $date3."";
> 
> The code above gives me the following output:
> 
> Fri Oct 11 2002
> Mon Feb 4 2002
> Wed Dec 31 1969
> 
> Is the strtotime() function causing this problem?
> Thanks.

What do you get with the following?




Torben


-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] strtotime question

2001-03-09 Thread Richard Lynch

0 is Sunday, 1 is Monday, 2 is Tuesday, ...

-- 
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message - 
From: Jason Murray <[EMAIL PROTECTED]>
Newsgroups: php.general
Sent: Tuesday, March 06, 2001 12:06 PM
Subject: [PHP] strtotime question


> Hi there,
> 
> $ob->date is '2000/03/06'.
> 
> $d = ereg_replace('([0-9]*)-([0-9]*)-([0-9]*)',
>   '\2/\3/\1', $ob->date);
> 
> $d is now '03/06/2000'.
> 
> $foo = getdate(strtotime($d)+86400);
> 
> Here I have to add an entire day to the value of strtotime($d) to get
> the expected results for below.
> 
> echo "" . $foo["weekday"] . ", " . $d . "\n";
> 
> Without adding a day to strtotime() $foo["weekday"] is 'Monday'.
> 
> Is there some kind of timezone stuff I am not accounting for? or is it
> something else?
> 
> Thanks,
> Jason
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]