• 4362阅读
  • 3回复

数据库里的时间输出来的时候中间多了一个T [复制链接]

上一主题 下一主题
离线downstairs
 

只看楼主 倒序阅读 楼主  发表于: 2011-05-25
— 本帖被 XChinux 从 C/C++基础 移动到本区(2011-05-28) —
数据里是
"2011-05-07  00:00:00"
querymode读取然后qDebug()输出来后变成了
"2011-05-07T00:00:00"
如何解决呀。中间为什么多了一个T呢。。大哥。实在是不解啊。。郁闷了。

在table里没有看到T 但是用DEBUG输出。或者是输出到文件。她就多了一个T。。
有遇到的么?
求解。谢谢
喜爱编程的猫头鹰
离线luoyang

只看该作者 1楼 发表于: 2011-05-25
不妨上下相关代码
离线downstairs

只看该作者 2楼 发表于: 2011-05-25
QString QDateTime::toString ( Qt::DateFormat format = Qt::TextDate ) const
This is an overloaded function.
Returns the datetime as a string in the format given.
If the format is Qt::TextDate, the string is formatted in the default way. QDate::shortDayName(), QDate::shortMonthName(), and QTime::toString() are used to generate the string, so the day and month names will be localized names. An example of this formatting is "Wed May 20 03:40:13 1998".
If the format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of dates and times, taking the form YYYY-MM-DDTHH:MM:SS.
喜爱编程的猫头鹰
离线downstairs

只看该作者 3楼 发表于: 2011-05-25
原来这是Qt::ISODate 标准的时间表示法啊。。。。替换字符串就OK了


            QVariant var=m->index(row,col).data();
            
            switch (var.type())
            {
            
            case QVariant::Type::DateTime:
                qDebug()<<var.toDateTime().toString(Qt::ISODate);
                break;
            }
喜爱编程的猫头鹰
快速回复
限100 字节
 
上一个 下一个