SQLite CURRENT_TIMESTAMP 总是 1970-01-01 [英] SQLite CURRENT_TIMESTAMP always 1970-01-01

查看:49
本文介绍了SQLite CURRENT_TIMESTAMP 总是 1970-01-01的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下定义表:

CREATE TABLE players(playerid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                     name VARCHAR(20) NOT NULL UNIQUE,
                     added DATETIME DEFAULT CURRENT_TIMESTAMP);

CURRENT_TIMESTAMP 无情地插入 1970-01-01.我大致了解这个日期的重要性,以及一些时间戳如何与其产生正/负偏移;但是,从我读过的其他地方来看,我的默认时间戳应该使用当前时间/日期,正如所建议的那样.另外,时间戳是否应该不包括时间(从 1970 年开始或其他时间)?

The CURRENT_TIMESTAMP relentlessly inserts 1970-01-01. I am loosely aware of the significance of this date and how some timestamps are a positive/negative offset from it; however, from what I've read elsewhere, my default timestamp should use the current time/date, as is suggests. Also, should a timestamp not include the time (from 1970 or otherwise)?

谢谢!:)

推荐答案

我突然顿悟,意识到自己是个白痴.我正在使用 Java 连接到数据库并使用 resultSet.getDate(" added"),这显然不适合此目的,并返回 1970-01-01>.getString(" added") 确认了我的错误,并准确返回了我想看到的内容:)

I just had an epiphany and realised I was being an idiot. I am using Java to connect to the database and was using resultSet.getDate("added"), which apparently is not suited to this purpose, and returns 1970-01-01. getString("added") confirmed my mistake, and returned exactly what I wanted to see :)

这篇关于SQLite CURRENT_TIMESTAMP 总是 1970-01-01的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆