Actual System Time

Hi Guys,

I was wondering if anyone could help me? I'm looking for a method to retrieve the actual system time. The time that I'm after is not the time that would be displayed on the user's clock, since this can be changed by the user, and is not a question relating to time zones, but the underlying time on which the actual time is calculated from.

The reason for this is I am hoping to have a time which cannot be changed by the owner of a device, so that when each device is first configured, it sends this time to the server so that it can by synchronized (by the server storing the difference between the device's system time & it's own against the device name in a database), and then offsetting the times in any data from this device by this amount. By doing this, even if the local time of the device were to be changed by the user after it's initial configuration, we would still get the time from the server (without the device needing to contact the server to get it's time). This would allow offline devices to be synchronized whilst protecting from user hacks.

Many thanks in advance,

JB

[1143 byte] By [Inversoa] at [2007-11-27 2:56:48]
# 1

"the local time of the device were to be changed by the user after it's initial configuration, we would still get the time from the server (without the device needing to contact the server to get it's time). This would allow"

That really does not sound possible.

To get a time other than the one on the local machine, you will need to go somewhere. If your application has access to some server you control, that sounds like the most logical place.

Maybe I am misunderstanding your post.

jbisha at 2007-7-12 3:34:50 > top of Java-index,Java Essentials,Java Programming...
# 2
I think he is asking if BIOS time is different to the OS time or may be there is some kind of machine time behind which exists and accessible ?
rym82a at 2007-7-12 3:34:50 > top of Java-index,Java Essentials,Java Programming...
# 3

Hi Guys,

it may be the BIOS time that I'm after - I'm not sure if this is updatable by the user or not - but certainly something along those lines. The figure I'm after is not necessarily a time, but could be a number from which the time is calculated; this figure is always updated, even if the device is turned off, from which the operating system calculates the time that it reports (by offsetting this number by a certain amount and transforming it to a time value to get the universal time, then offsetting this amount again for the time zone).

The issue is that I cannot rely on the time given by the operating system, since this could be changed by the user, allowing them to fake results by putting their time back one hour, using the program, then putting their time forwards an hour so that the change of time is undetectable when it's connected back to the server, whilst the time figure stored against the program activity is 1 hour earlier. I cannot rely on a time from the server since the devices (laptops / windows mobiles) are taken out in the field where they are used offline (i.e. with no connection to any other device capable of giving the time) for use, then report their figures in a batch update at the end of the day.

I hope that makes a bit more sense / clarifies up what I'm after. If anyone can think of other methods that may work, I'd also welcome these.

Thanks again,

JB

Inversoa at 2007-7-12 3:34:50 > top of Java-index,Java Essentials,Java Programming...
# 4
I cannot image any time on a PC (not sure about other devices like cell phones) that cannot be updated by the user.Not sure what you are trying to accomplish - would something be gained by the user to fake the time?
jbisha at 2007-7-12 3:34:50 > top of Java-index,Java Essentials,Java Programming...
# 5

I'm afraid that even RTC (BIOS) time can be changed by a user who has access to the bios setup.

If you really need the code the only suggestion I can think of is to consult developers who regularly edit and/or compile the linux kernel. Although it's written in C++, something may be gained by going through it and trying to understand how it's done (if the code can be found, that is).

Hope this help in some small way!

Good Luck!

burgs

burgsa at 2007-7-12 3:34:51 > top of Java-index,Java Essentials,Java Programming...
# 6

Hi folks,

thanks for all the feedback; it seems that you're right about users being able to change the time even at hardware level & about my proposed solution being impossible. For anyone coming to this post looking for a similar solution, here's what I've found out.

I had thought that the date & time were kept up to date by a hardware clock that constantly ran (even when the computer was turned off), that the system could use to work out universal time (by offsetting the hardware clock by an offset amount given when the time was last synchronised), and then the OS applied the time zone to this corrected time.

This is not far off what actually happens, except that in my theory, the hardware clock ran all the time, with the system time being offset from it, but running in parallel. What actually seems to happen is that when the computer boots up, the hardware time is read in as the system time (taken as either universal or local depending on the OS / config). The OS then applies the time zone offset as required (depending if an application asks for local or universal). However, when the system is shutdown, it updates the hardware clock with its own time (since the hardware clock is not very accurate, the OS time is considered more reliable since it is likely to have been synchronised with a more accurate clock). This means that should a user change the time, when the device is shutdown, the hardware clock is updated with the user's correction.

The only solution to my problem therefore seems to be to use universal time (avoiding daylight savings issues), have the system synchronise with the server when possible, and use security to block the users from altering the time.

Thanks again,

JB

Inversoa at 2007-7-12 3:34:51 > top of Java-index,Java Essentials,Java Programming...
# 7
And why not just use the server time?Presumably the client sends something to the server? So why not have the server timestamp it rather than relying on the client?
jschella at 2007-7-12 3:34:51 > top of Java-index,Java Essentials,Java Programming...