You are not logged in.
I need to convert ServerTimeStamp, UTC time, to local time.
Any hints?
Offline
I believe you can use TSynTimezone for this:
localtime = UtcToLocal(TimeLogToDateTime(Server.ServerTimeStamp), 'Your Timezone');
See: https://synopse.info/forum/viewtopic.php?id=5976
But docs says:
/// the current Date and Time, as retrieved from the server
// - note that this value is the DB_SERVERTIME[] constant SQL value, so
// will most likely return a local time, not an UTC time ...
property ServerTimestamp: TTimeLog
Offline
I believe you can use TSynTimezone for this:
localtime = UtcToLocal(TimeLogToDateTime(Server.ServerTimeStamp), 'Your Timezone');
Thank you.
But docs says:
property ServerTimestamp: TTimeLog
That's different from the source code comments. In mORMot.pas, TSQLRest.ServerTimeStamp says
/// the current UTC Date and Time, as retrieved from the server
// - this property will return the timestamp as TTimeLog / Int64
Offline
Hi ab,
We are referring to that in one part of the documents it says that it returns UTC and in another the local time.
mormot1
SynDB.pas
/// the current Date and Time, as retrieved from the server
// - note that this value is the DB_SERVERTIME[] constant SQL value, so
// will most likely return a local time, not an UTC time
mORMot.pas
/// the current UTC Date and Time, as retrieved from the server
// - this property will return the timestamp as TTimeLog / Int64
mormot2
motmot.db.sql.pas
/// the current Date and Time, as retrieved from the server
// - note that this value is the DB_SERVERTIME[] constant SQL value, so
// will most likely return a local time, not an UTC time
Offline
Those are not the same values.
The one from SynDB or motmot.db.sql.pas is not the one from TSQLRest instances.
The first comes from the DB itself, from executing a SQL statement depending on the engine. It may or may not be the local time. Its purpose is to have the same time as may have been stored in regular SQL statements.
The TSQLRest time is always the UTC REST server time as returned by the OS. It is the time used by the ORM to fill created/modified timestamps fields.
Offline
Thanks for clarification
Offline