Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Did you change the date? 1

Status
Not open for further replies.

northrd

Programmer
May 18, 2003
74
AU
I have a date/time critical application that must not allow the user the retrospectively add records to the database. In other words they are NOT allowed to change the system date to , say, yesterday and then add(or for that matter alter or delete) a record.

I would love to "ping" off a time server site thingy that has the current date/time of my city irrespective of daylight saving at the source or my location. This, to me, seems to be the definitive way of testing if someone is being "naughty". Thus far I have found numerous sites that return local(server) date/time only. Does anyone know of a server that returns "my" date/time?

Else ...

Does anyone have another approach.

Cheers
 
You could store Now in a variable and check it in a Timer routine. If (current) Now is <> (previous) Now +/- your tolerance then change it back.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
In my opinion, it's best to make everyone play by the same rules. In this case, the common denominator is the database. So... whenever you need to know what time it is, use the database to tell you. The database will report the date and time of the computer that the database is running on. It may not be accurate, but it will at least be consistent among your users.

If you are using Microsoft SQL Server, it's a simple query to run.

[tt][blue]Select GetDate() As DatabaseDateTime[/blue][/tt]

If you're using another database engine, the function call may be different, but it probably exists.

Actually, what I recommend is that you stop using the client's date/time completely. When you insert a row in the database, you could hard code GetDate() instead of using the client's date time.

Make sense?



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
gmmastros

Looks great. A simple yet elegant solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top