SilkPerformer gives a function to retrieve a formatted time string in the local time but not in GMT. Here's a little function that will fetch the current GMT time in the specified format. Of course, if there are better ways to do it, please feel free to share.
- function ESGGetGMTDateTime(
- psFormat : string optional
- ) : string
- var
- sDateTime : string;
- sFormat : string init "%Y-%m-%dT%H:%M:%SZ";
- nDateCurr : number;
- nTimeCurr : number;
- begin
- if Strlen(psFormat) > 0 then sFormat := psFormat end;
- nDateCurr := GetCurrentDate();
- nTimeCurr := GetCurrentTime();
- nTimeCurr := nTimeCurr + (GetTime(TIME_GMT) - GetTime(TIME_LOCAL));
- if nTimeCurr >= 86400 then
- nDateCurr := IncDate(nDateCurr, 1);
- nTimeCurr := nTimeCurr - 86400;
- elseif nTimeCurr < 0 then
- nDateCurr := IncDate(nDateCurr, -1);
- nTimeCurr := 86400 + nTimeCurr;
- end;
- FormatDateTime(nDateCurr, nTimeCurr, sFormat, sDateTime);
- ESGGetGMTDateTime := sDateTime;
- end ESGGetGMTDateTime;
No comments:
Post a Comment