I’m writing an app which has a “check in” facility – essentially a system tray app that checks in every 20 seconds by writing to a SQL db.
I then have a second app that checks this table to see if the client has checked in, and performs an action if the client has not checked in for 60 seconds.
I need to ensure that the time written to the sql database is the local server time, not the client time – as otherwise I’ll have synchronisation issues.
I’m using Linq-to-SQL – how can I acheive this?
Actually as a general rule of thumb you should not use the local time of the server either – use UTC time (Coordinated Universal Time) instead.
In Linq to Sql you can use
SqlFunctions.GetUtcDate()for this which maps toGETUTCDATE()in SQL Server.