12-10-2015 04:13 PM
I am using the 'Get Date/Time in Seconds' function in a loop with a shift register to calculate the amount of time between loop interations. This is in a LV2012 exe running many hours each day. On random occasions the timestamp coming out of the function loses an hour -- goes from say 3:12:13PM to 2:12:13PM (the date doesn't change). Once it loses the hour it counts up normally from that point. This started about 6 weeks ago and happens from a couple times a day to every couple of days. Has anyone ever seen something like this and how did you fix it?
12-10-2015 04:24 PM - edited 12-10-2015 04:25 PM
Can you post code?
Anything greater that 2012, I can't open.
12-10-2015 05:50 PM
The full program is rather involved, but I've reproduced the problem code in the attached (LV2012). Finally figured out what was happening when I put some logging into the program to determine why the math using the time difference would shift. We were able to capture the following transition:
last read time | current read time | time diff |
3:28:48 PM | 3:28:48 PM | 0.100006 |
3:28:48 PM | 2:28:49 PM | -3599.9 |
2:28:49 PM | 2:28:49 PM | 0.100006 |
12-10-2015 07:15 PM
12-10-2015 08:20 PM
12-10-2015 08:30 PM
@ben64 wrote:
That's strange. Since it is an exe this issue is problably more on the PC side. Any updates or modifications? Note that around 6 weeks ago there was the time change but since it run ok most of the time it's probably just a coincidence.
My very first thought was "Didn't DST just end, which would cause the clock to go back an hour?"
The Get Date/Time function gets the time from the system clock. I would be watching that. Perhaps it is IT trying to set the time on you.
12-10-2015 08:38 PM
Mike,
The sample doesn't exihibit the problem. It is just to show how the function is used. I have used code like this in dozens of applications over 10+ years and this is the only time I've seen anything like this. On the machine that shows the problem, the client first said that it happened almost every time the program was running for about 30 minutes. However, I don't think it is quite as repeatable as they thought since it took them four weeks of trying to capture a log with the event. The log code was pretty simple and they were to start the log once they got close to the 30 minute time and then shut it off once they either saw the event or had run well over the 30 minute mark. I didn't have the log constantly active because I didn't want to fill up the hard drive with log files.
12-10-2015 08:46 PM
crossrulz,
I didn't think about IT trying to set the time. I don't think this PC is on their network, but will check with them.
Thanks
12-11-2015 03:37 AM
We normally set the timezone on any rig/measurement PCs to UTC and/or log the date/time in UTC to avoid these weird issues around timestamps being off by an hour!
12-11-2015 08:51 AM - edited 12-11-2015 08:53 AM
What version of Windows? Does it occur after a shutdown of the computer? Does the BIOS clock interact with Windows clock? Might be worth checking out.
https://support.microsoft.com/en-us/kb/899855