Save Date on SQL Server with wrong timezone

I have this:

Clock = Date.now();
this.newReport.DateTime = new Date(this.Clock);

Client side the date is ok: Mon May 20 2019 19:08:34 GMT+0200 But on SQL Server it is save with time 17:08

Why? Thanks

Upvotes: 0

Views: 354

Answers (1)

Adrian
Adrian

Reputation: 91

It looks like that's the same date, when you include the Timezone offset. If the "client side" date is GMT +0200, then the datetime stored should be 17:08:34 (as GMT time).

You're not including much detail, but I expect that you are wanting to save the time as local time. You could either convert the time to Localtime before saving it (and lose the additional information about the timezone), or save the GMT offset along with the date and time so that you could have both available if you wanted to convert it back to localtime later.

Upvotes: 1

Related Questions