delphi如何将twitter时间戳转换为TDatetime

non*_*one 2 delphi twitter delphi-2009 formatdatetime

继续这个问题: 如何将Twitter时间戳转换为DateTime?

将twitter日期时间戳转换为TDateTime的代码是什么?

edit:StrDateTime(const string; TFormatSettings);

可以处理其中的一些,现在只是想弄清楚如何引入新的格式.

Chr*_*ton 5

由于我们没有ParseExact函数,因此您需要在位置上解析时间戳的组件.您可以使用Copy()函数执行此操作.例如:

TheMonthAsString := Copy(TwitterDate,5,3);
TheDayAsString := Copy(TwitterDate,9,2);
etc..
Run Code Online (Sandbox Code Playgroud)

将这些片段转换为整数,然后您可以使用EncodeDateTime(在DateUtils单元中)(感谢Jens!)生成TDateTime.

摘要:将字符串拆分为时间戳的各个组件,并使用EncodeDateTime或StrToDateTime将其转换为TDateTime.