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 to GETUTCDATE()
in SQL Server.
Write a user defined function that returns GetDate()
and add it to you dbml file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With