Best Practice Date & Time Recording

I am creating a simple CMS for managing articles. My MS SQL Server 2008 is located in the USA, the author of the database is in the USA and Germany.

When the author creates an article in the database, I would like to write down the date of creation.

I would like to show the date on the website, as all content and articles are created from Germany.

My questions: A) - shell Do I use SYSDATETIMEOFSFS () as DEFAULT in DataBase and at the level of business logic converted to German time?

B) - I have to add DATE from the business logic level directly, not allowing DataBase to add date-time and showing the data as is ?.

Hope my question is clear. If you can send me some kind of link resource, I would appreciate

Thanks guys: -)

+3
source share
3 answers

Save dates in UTC format with a clockwise offset, use this date in the application.

At the last moment, convert to a local time display.

The best methods for datetime, daylight saving time, and time zones are compiled in this question.

+6
source

My recommendation would be to go with UTC - so you have an absolute reference system.

This is done in SQL Server using

select getutcdate()
+3
source

, , .

/ , , , BL/Presentation Layer. , !

0
source

Source: https://habr.com/ru/post/1758356/


All Articles