有什么好的算法可以把串“15/Aug/2003:00:46:16”变成"2003-08-15 00:46:16"?

jas_liu 2003-08-26 11:30:18
xiexie
...全文
35 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
jlzhaoji 2003-08-27
  • 打赏
  • 举报
回复
关注
hy1080 2003-08-27
  • 打赏
  • 举报
回复
我也做个记号
happyer 2003-08-26
  • 打赏
  • 举报
回复
同意楼上的!
标记以示关注。
myan18 2003-08-26
  • 打赏
  • 举报
回复
String datetime;
datetime=FormatDateTime("yyyy-mm-dd hh:mm:ss",StrToDateTime(Edit1->Text)
//Edit1->Text可换成相应的字符串
ShowMessage(DateTimeToStr(datetime));
netsys2 2003-08-26
  • 打赏
  • 举报
回复
根据规律自己编程序切分字串,再重新组合,不难的。
netsys2 2003-08-26
  • 打赏
  • 举报
回复
根据规律自己编程序切分字串,再重新组合,不难的。
jas_liu 2003-08-26
  • 打赏
  • 举报
回复
还要考虑一年的12个月份
jingrunx 2003-08-26
  • 打赏
  • 举报
回复
把mktime(&t)改为mktime(&t) - _timezone
jingrunx 2003-08-26
  • 打赏
  • 举报
回复
#include <time.h>
#include <DateUtils.hpp>
void __fastcall TForm1::Button2Click(TObject *Sender)
{
struct tm t;
char timestr[] = "15/Aug/2003:00:46:16";
strptime(timestr, "%d/%b/%Y:%H:%M:%S", &t);

AnsiString x = UnixToDateTime(mktime(&t)).FormatString("yyyy-mm-dd hh:mm:ss");
}


不过这个函数有个毛病:会根据时区调整,你看到的输出时间可能晚8个小时
明天我到公司把时区转换拷贝过来,再说。
jas_liu 2003-08-26
  • 打赏
  • 举报
回复
"15/Aug/2003:00:46:16" is not a valid date and time.
HeLZ 2003-08-26
  • 打赏
  • 举报
回复
倒了,看错字符了.
HeLZ 2003-08-26
  • 打赏
  • 举报
回复
try
{
StrToDateTime("15/Aug/2003:00:46:16").FormatString("yyyy-mm-dd hh:nn:ss");
//是hh:nn:ss 不是hh:mm:ss
}
catch(...)
{
//...
}
tokens 2003-08-26
  • 打赏
  • 举报
回复
这还能有什么好的算法??
只是月份可能要做一个表来对应了。。
比如:
Aug 8
做个转换就行了。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧