the following script...
<?php
$times = array(
'2004-04-04 00:31:00-06',
'2004-04-04 01:00:00-06',
'2004-04-04 01:59:59-06',
'2004-04-04 02:00:00-06',
'2004-04-04 03:00:00-06',
);
for ($i = 0; $i < count($times); $i++)
{
$s = $times[$i];
$time_t = strtotime($s);
print "strtotime('$s') = $time_t\n";
print "date('r', $time_t) = \"" . date('r', $time_t) . "\"\n";
print "\n";
}
?>
generates this output:
strtotime('2004-04-04 00:31:00-06') = 1081060260
date('r', 1081060260) = "Sat, 3 Apr 2004 23:31:00 -0700"
strtotime('2004-04-04 01:00:00-06') = 1081062000
date('r', 1081062000) = "Sun, 4 Apr 2004 00:00:00 -0700"
strtotime('2004-04-04 01:59:59-06') = 1081065599
date('r', 1081065599) = "Sun, 4 Apr 2004 00:59:59 -0700"
strtotime('2004-04-04 02:00:00-06') = 1081069200
date('r', 1081069200) = "Sun, 4 Apr 2004 03:00:00 -0600"
strtotime('2004-04-04 03:00:00-06') = 1081069200
date('r', 1081069200) = "Sun, 4 Apr 2004 03:00:00 -0600"
date() seems to be picking rather arbitrary timezones for output.
Secondly, as best as I can tell, the fourth output is just patently WRONG
(or I'm too dense to see what's going on, but I don't think so).
I often want to calculate a time_t value at 00:00:00 (midnight) for an
arbitrary input time_t. I had been doing this as:
$midnight = strtotime(date('Y-m-d', $time_t));
but given the behaviour above, I don't think this works reliably. :(
The machine this is running on happens to be in MDT right now
(offset -06) and running PHP version 4.1.0. Can someone help me figure out
what the hell is going on here (or a *reliable* way to get a time_t value
for midnight of input strings of the form strtotime() handles)?
Thanks in advance.
-ej 2 1989
Erik Johnson wrote: the following script...
<?php
$times = array( '2004-04-04 00:31:00-06', '2004-04-04 01:00:00-06', '2004-04-04 01:59:59-06',
As per information on http://www.timeanddate.com/
before switching over to MDT the timezone offset was -0700
'2004-04-04 02:00:00-06',
This particular time did not happen.
MDT started on the second after 2004-04-04 01:59:59 (local time -- MST)
which was 2004-04-04 03:00:00 (local time -- MDT)
'2004-04-04 03:00:00-06', );
for ($i = 0; $i < count($times); $i++) { $s = $times[$i]; $time_t = strtotime($s); print "strtotime('$s') = $time_t\n"; print "date('r', $time_t) = \"" . date('r', $time_t) . "\"\n"; print "\n"; }
?>
generates this output:
strtotime('2004-04-04 00:31:00-06') = 1081060260 date('r', 1081060260) = "Sat, 3 Apr 2004 23:31:00 -0700"
Wrong input
strtotime('2004-04-04 01:00:00-06') = 1081062000 date('r', 1081062000) = "Sun, 4 Apr 2004 00:00:00 -0700"
Wrong input
strtotime('2004-04-04 01:59:59-06') = 1081065599 date('r', 1081065599) = "Sun, 4 Apr 2004 00:59:59 -0700"
Wrong input
strtotime('2004-04-04 02:00:00-06') = 1081069200 date('r', 1081069200) = "Sun, 4 Apr 2004 03:00:00 -0600"
Wrong input
strtotime('2004-04-04 03:00:00-06') = 1081069200 date('r', 1081069200) = "Sun, 4 Apr 2004 03:00:00 -0600"
OK :)
date() seems to be picking rather arbitrary timezones for output. Secondly, as best as I can tell, the fourth output is just patently WRONG (or I'm too dense to see what's going on, but I don't think so).
Confused by timezone changes (and their respective offset)? :)
I often want to calculate a time_t value at 00:00:00 (midnight) for an arbitrary input time_t. I had been doing this as:
$midnight = strtotime(date('Y-m-d', $time_t));
but given the behaviour above, I don't think this works reliably. :(
Let's abolish DST !!!!!
--
USENET would be a better place if everybody read: : mail address : http://www.catb.org/~esr/faqs/smart-questions.html : is valid for : http://www.netmeister.org/news/learn2quote2.html : "text/plain" : http://www.expita.com/nomime.html : to 10K bytes :
"Pedro Graca" <he****@hotpop.com> wrote: Confused by timezone changes (and their respective offset)? :)
Yes. That's it (DOH!). ;) I forgot this had happened - I happened to be
looking at date/time stuff anyway.
Was very stressed out yesterday with a number of other things - not thinking
clearly.
Thank you for your reply. :)
-ej
in message news:c4*************@ID-203069.news.uni-berlin.de... Erik Johnson wrote: the following script...
<?php
$times = array( '2004-04-04 00:31:00-06', '2004-04-04 01:00:00-06', '2004-04-04 01:59:59-06',
As per information on http://www.timeanddate.com/
before switching over to MDT the timezone offset was -0700
'2004-04-04 02:00:00-06',
This particular time did not happen. MDT started on the second after 2004-04-04 01:59:59 (local time -- MST) which was 2004-04-04 03:00:00 (local time -- MDT)
'2004-04-04 03:00:00-06', );
for ($i = 0; $i < count($times); $i++) { $s = $times[$i]; $time_t = strtotime($s); print "strtotime('$s') = $time_t\n"; print "date('r', $time_t) = \"" . date('r', $time_t) . "\"\n"; print "\n"; }
?>
generates this output:
strtotime('2004-04-04 00:31:00-06') = 1081060260 date('r', 1081060260) = "Sat, 3 Apr 2004 23:31:00 -0700"
Wrong input
strtotime('2004-04-04 01:00:00-06') = 1081062000 date('r', 1081062000) = "Sun, 4 Apr 2004 00:00:00 -0700"
Wrong input
strtotime('2004-04-04 01:59:59-06') = 1081065599 date('r', 1081065599) = "Sun, 4 Apr 2004 00:59:59 -0700"
Wrong input
strtotime('2004-04-04 02:00:00-06') = 1081069200 date('r', 1081069200) = "Sun, 4 Apr 2004 03:00:00 -0600"
Wrong input
strtotime('2004-04-04 03:00:00-06') = 1081069200 date('r', 1081069200) = "Sun, 4 Apr 2004 03:00:00 -0600"
OK :)
date() seems to be picking rather arbitrary timezones for output. Secondly, as best as I can tell, the fourth output is just patently
WRONG (or I'm too dense to see what's going on, but I don't think so).
Confused by timezone changes (and their respective offset)? :)
I often want to calculate a time_t value at 00:00:00 (midnight) for
an arbitrary input time_t. I had been doing this as:
$midnight = strtotime(date('Y-m-d', $time_t));
but given the behaviour above, I don't think this works reliably. :(
Let's abolish DST !!!!!
-- USENET would be a better place if everybody read: : mail address : http://www.catb.org/~esr/faqs/smart-questions.html : is valid for : http://www.netmeister.org/news/learn2quote2.html : "text/plain" : http://www.expita.com/nomime.html : to 10K bytes : This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: nyso |
last post by:
Hi,
I've got a string that contains a date with the following format :
yyyy-mm-dd hh:mm:ss
ex :
2003-10-10 11:37:47
I'd like to get 4 variables :
- 1 for the year number,
- 1 for the month,
|
by: cover |
last post by:
Anyone know how to enter the time into a form or a website that might
tell how? I'm using the following html code and trying to get the
time to default into the text box. thanks
html code...
|
by: Gerrit Holl |
last post by:
Posted with permission from the author.
I have some comments on this PEP, see the (coming) followup to this message.
PEP: 321
Title: Date/Time Parsing and Formatting
Version: $Revision: 1.3 $...
|
by: Kalle Anke |
last post by:
I want to parse a date string, for example '2005-09-23', and since I haven't
done this before I would like to ask what is the best way to do it.
I've looked around and the dateutil seems to be...
|
by: Matt |
last post by:
Given a date, how to find the beginning date and ending date of that week
please advise!
|
by: placid |
last post by:
how would i get the current date in the format of DD/MM/YYYY, do i use
functions in time.h and how would i compile it (linking) ?
|
by: richard |
last post by:
I'm just dealing with a Roundup bug report in which it's pointed out that
time.strftime() doesn't produce RFC2822-compliant date strings when in a
locale other than "C".
My reading of the RFC...
|
by: shsandeep |
last post by:
I used the following query to retrieve the date in dd-mon-yyyy format.
db2 => SELECT RTRIM(CHAR(DAY(COVG_TYP_STRT_DT))) || '-' ||
RTRIM(MONTHNAME(COVG_TYP_STRT_DT)) || '-' ||...
|
by: kaydubbleu |
last post by:
I have stumbled across what I think seems to be a weird situation, and
was hoping that maybe someone out there could point me in the
direction as to why it is occuring.
$date = '2008-09-16';
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |