You are not logged in.
Pages: 1
Hello,
There are some web services insisting on "yyyy-mm-dd hh:nn:ss" format. Sometimes they even put only php format string "Y-m-d H:i:s" as their requirement.
Is it possible to have mORMot2 to serialize TDateTime values using a custom format?
Thanks & Regards,
Ertan
Offline
You can overwrite the TDateTime format, but it would be global for the whole process.
IMHO this is not a good idea.
I would just use a RawUtf8 field with manual serialization instead.
Online
I am returning back to this specific date time format.
I see it can be de-serialized successfully into TDateTime if the field name is "timestamp" like below
type
TRec = packed record
timestamp: TDateTime;
end;
procedure TForm1.FormCreate(Sender: TObject);
const cData = '{"timestamp":"2024-08-02 21:02:13"}';
var LRec: TRec;
begin
mormot.core.json.RecordLoadJson(LRec, RawUtf8(cData), TypeInfo(TRec));
end;
I wonder if it is possible to widen this for TDateTime definitions using any name?
Thank you for your consideration.
Regards,
Ertan
Offline
You can overwrite the TDateTime format, but it would be global for the whole process.
I don't know how I can do that?
Offline
Pages: 1