473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Why Date() goes backwards


I made a test page that just outputs about 100 date('Y-m-d H:i:s');

Occationally (say, 1 out of 30 tries) the time goes backwards by one or
two seconds. Like:

2006-11-14 07:29:16
2006-11-14 07:29:16
2006-11-14 07:29:16
2006-11-14 07:29:14
2006-11-14 07:29:14
2006-11-14 07:29:14

Or even reloading the page, the 2nd page will show an earlier time than
the first page by one or two seconds.

It's no big deal. It's just interesting. I wonder, how can this happen?

Terry
Nov 14 '06 #1
5 1115
>I made a test page that just outputs about 100 date('Y-m-d H:i:s');
>
Occationally (say, 1 out of 30 tries) the time goes backwards by one or
two seconds. Like:

2006-11-14 07:29:16
2006-11-14 07:29:16
2006-11-14 07:29:16
2006-11-14 07:29:14
2006-11-14 07:29:14
2006-11-14 07:29:14

Or even reloading the page, the 2nd page will show an earlier time than
the first page by one or two seconds.

It's no big deal. It's just interesting. I wonder, how can this happen?
Is the server time synchronized to anything? NTP tries to avoid large
jumps like that, but other methods (like maybe "net time" or "ntpdate")
might not.

Nov 15 '06 #2
In article <12*************@corp.supernews.com>,
go***********@burditt.org (Gordon Burditt) wrote:
I made a test page that just outputs about 100 date('Y-m-d H:i:s');

Occationally (say, 1 out of 30 tries) the time goes backwards by one or
two seconds. Like:

2006-11-14 07:29:16
2006-11-14 07:29:16
2006-11-14 07:29:16
2006-11-14 07:29:14
2006-11-14 07:29:14
2006-11-14 07:29:14

Or even reloading the page, the 2nd page will show an earlier time than
the first page by one or two seconds.

It's no big deal. It's just interesting. I wonder, how can this happen?

Is the server time synchronized to anything? NTP tries to avoid large
jumps like that, but other methods (like maybe "net time" or "ntpdate")
might not.
I have asked my host. It's the same for time() and microtime(), and it
jumps forwards and back, like this:

This is with date() (time()) (microtime()):

2006-11-14 14:30:56 (1163543456) (1163543456.4591)
2006-11-14 14:30:56 (1163543456) (1163543456.4592)
2006-11-14 14:30:56 (1163543456) (1163543456.4593)
2006-11-14 14:30:56 (1163543458) (1163543458.0658)
2006-11-14 14:30:58 (1163543458) (1163543458.0659)
2006-11-14 14:30:58 (1163543458) (1163543458.066)
2006-11-14 14:30:58 (1163543458) (1163543458.0661)
2006-11-14 14:30:58 (1163543458) (1163543458.0662)
2006-11-14 14:30:58 (1163543458) (1163543458.0663)
2006-11-14 14:30:58 (1163543458) (1163543458.0664)
2006-11-14 14:30:58 (1163543458) (1163543458.0665)
2006-11-14 14:30:58 (1163543458) (1163543458.0666)
2006-11-14 14:30:58 (1163543456) (1163543456.4649)
2006-11-14 14:30:56 (1163543456) (1163543456.465)
2006-11-14 14:30:56 (1163543456) (1163543456.4652)
2006-11-14 14:30:56 (1163543456) (1163543456.4653)
2006-11-14 14:30:56 (1163543456) (1163543456.4654)

Those are 1.6 second jumps. It's like there are two clocks.
Nov 15 '06 #3
just a guess, Your ISP may be running clustered servers with a set of
servers handing the php engine and a separate one handling databases
and using with load balancing to switch the server handling the PHP
request and the time is coming from the server directed to handle the
request. Sometimes you will get server A and sometimes server B and
the clocks are very slightly apart. If the error is always the same
value (1.6 seconds) then I would sumise that this is almost definately
the answer.

Obiron

Nov 15 '06 #4
frothpoker wrote:
just a guess, Your ISP may be running clustered servers with a set of
servers handing the php engine and a separate one handling databases
and using with load balancing to switch the server handling the PHP
request and the time is coming from the server directed to handle the
request. Sometimes you will get server A and sometimes server B and
the clocks are very slightly apart. If the error is always the same
value (1.6 seconds) then I would sumise that this is almost definately
the answer.
Wow. I woulda said the OP was doing something
wrong... but that's a much more likely answer.
Nov 15 '06 #5
..oO(frothpoker)
>Sometimes you will get server A and sometimes server B
Within a single script request?

Micha
Nov 15 '06 #6

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

Similar topics

2
by: puREp3s+ | last post by:
Hi I have a table that contains information that has start dates and end dates. They are stored in short date format. I have built a web page that initially returned all the information. I...
7
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r =...
8
by: Dennis M. Marks | last post by:
What is the maximum valid date range for the date(yyyy,mm,dd) function. -- Dennis M. Marks http://www.dcs-chico.com/~denmarks/ Replace domain.invalid with dcsi.net -----= Posted via...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
1
by: joeyej | last post by:
I'm using this code to make sure users are unable to choose a date from a drop list (<option value="June 8, 2006, (Thursday), 9am">June 12, 2006, (Thursday), 9am) that is less than two days out...
10
by: Daniel | last post by:
In Microsoft Access I can write a query that includes the criteria: Between Date()-7 And Date() to retrieve the records from a table that fall within the last week. I'm trying to write a...
2
by: John Smith | last post by:
Hello, I have a VB.NET application with a Windows form that have several textboxes fields where I have dates entered. I would like to do a date validation check after the the field is updated, so...
1
by: cppaddict | last post by:
I have dates like "8/27" or "9/4", and I need to convert them to date objects. When choosing a year, we should go backwards until we find the first match. That is, if the script runs on Jan 1,...
5
by: thecheyenne | last post by:
Hi there and happy new year to all of you. I've been reading the thread "Auto Date in form "pages" from 'frys' in the topics and his/her problem is similar though not identical to mine. Here is my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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

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