我需要与 MySQL 等效的 SQLite 来处理 unix 时间戳 [英] I need the SQLite equivalent of MySQL for working with unix timestamps

查看:27
本文介绍了我需要与 MySQL 等效的 SQLite 来处理 unix 时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SQLite 中使用 unix 时间戳并将它们存储为整数.我的问题是我试图根据它们的 unix 时间戳选择今天的记录,但我不知道要使用哪些函数.

I'm using unix timestamps with SQLite and storing them as an integer. My problem is that I am trying to select records for today based on their unix timestamps and I have no clue what functions to use.

这是我将在 MySQL 中使用的内容:

Here is what I would use in MySQL:

where date_format(from_unixtime(COLUMN_DATE), '%Y-%m-%d')= date_format(now(), '%Y-%m-%d')

但是,当我尝试使用这些函数时,我在日志中收到错误消息,告诉我 SQLite 不存在这些函数.

However when I try to use these functions I'm getting errors in the log telling me they don't exist for SQLite.

我如何为 SQLite 编写这个?

How do I write this for SQLite?

推荐答案

SQLite 日期和时间函数记录在 http://sqlite.org/lang_datefunc.html.

SQLite date and time functions are documented at http://sqlite.org/lang_datefunc.html.

相当于你的 WHERE 子句是

WHERE date(COLUMN_DATE,'unixepoch') = date('now')

这篇关于我需要与 MySQL 等效的 SQLite 来处理 unix 时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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