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

标签 delphi twitter delphi-2009 formatdatetime

继续这个问题: How to Convert Twitter Timestamp to DateTime?

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

编辑: StrDateTime(const string;TFormatSettings);

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

最佳答案

由于我们没有 ParseExact 函数,因此您需要按位置解析时间戳的组成部分。您可以使用 Copy() 函数来完成此操作。例如:

TheMonthAsString := Copy(TwitterDate,5,3);
TheDayAsString := Copy(TwitterDate,9,2);
etc..

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

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

关于delphi如何将twitter时间戳转换为TDatetime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7386834/

相关文章:

delphi - 我可以生成自定义编译器错误吗?如果是这样,怎么办?

delphi - 如何防止用户更改系统日期/时间(在 Windows 7 中)?

delphi - 如何使用delphi在openGL中渲染简单的2d文本?

delphi - 在 Delphi 2009 上安装最新版本的 Indy 10

listview - 如何更改 TListGroups 中的组顺序?

c - 同步ReadFile读取的字节数

java - 为什么我不能在 Selenium/HtmlUnit 的字段中输入文本?

python - 通过 Python 抓取 Twitter 嵌入 URL

delphi - Indy,ADO和Delphi 2009的问题