关于Qt日期

1、这里读数据库上来的数据是(equipID.begin_soc)uint seconds 
2、使用静态函数
QString strST="";
QString strStartitem="";
QDateTime sTime;
sTime = QDateTime::fromTime_t(equipID.begin_soc);
3、将QDateTime转换成字符串
strST = sTime.toString("yyyy-MM-dd hh:mm:ss:zzz");








下面是表示年月等保留多少位
Expression
Output
d
the day as number without a leading zero (1 to 31)
dd
the day as number with a leading zero (01 to 31)
ddd
the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName().
dddd
the long localized day name (e.g. 'Monday' to 'Sunday'). Uses QDate::longDayName().
M
the month as number without a leading zero (1-12)
MM
the month as number with a leading zero (01-12)
MMM
the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName().
MMMM
the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName().
yy
the year as two digit number (00-99)
yyyy
the year as four digit number


Note: Unlike the other version of this function, day and month names must be given in the user's local language. It is only possible to use the English names if the user's language is English.
These expressions may be used for the time part of the format string:
Expression
Output
h
the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hh
the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
H
the hour without a leading zero (0 to 23, even with AM/PM display)
HH
the hour with a leading zero (00 to 23, even with AM/PM display)
m
the minute without a leading zero (0 to 59)
mm
the minute with a leading zero (00 to 59)
s
the second without a leading zero (0 to 59)
ss
the second with a leading zero (00 to 59)
z
the milliseconds without leading zeroes (0 to 999)
zzz
the milliseconds with leading zeroes (000 to 999)
AP or A
interpret as an AM/PM time. AP must be either "AM" or "PM".
ap or a
Interpret as an AM/PM time. ap must be either "am" or "pm".
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值