I am using Facebook graph API in my application. Facebook API returns an array of objects as response. For each item in the array, there is an object created_time which denotes the time of post. I need to convert that datetime into Delphi TDateTime so that I can have mm/dd//yy hh:mm:ss format time.
ArrayItem:
{
"created_time": "2015-10-12T01:56:25+0000",
"link": "http://exampleeeeee.com",
"id": "349561906753_10154021323131754"
}
By the way Facebook returns the datetime in other format as well but I am eager to learn this.
The date format is ISO 8601 and you can convert it using the XMLTimeToDateTime
function in the XSBuiltIns unit.
uses
XSBuiltIns;
procedure TForm1.FormCreate(Sender: TObject);
var
ISO8601StrA, ISO8601StrB: String;
Dt: TDateTime;
begin
ISO8601StrA := '2015-10-12T01:56:25+0000';
Dt := XMLTimeToDateTime(ISO8601StrA);
ISO8601StrB := DateTimeToXMLTime(Dt, False);
end;