sqlite3中时间函数

前端之家收集整理的这篇文章主要介绍了sqlite3中时间函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

datetime()/datetime('now')显示的是零时区的时间,"YYYY-MM-DD HH:MM:SS"

如果要获得当前时区的可以 datetime('now','localtime')

如果知道是哪个时区的:datetime('now','-3 hours')

其它的时间函数:(摘自官网)

  1. date(timestring,modifier,...)
  2. time(timestring,...)
  3. julianday(timestring,...)
  4. strftime(format,timestring,...)

Examples

Compute the current date.

SELECT date('now');

Compute the last day of the current month.

SELECT date('now','start of month','+1 month','-1 day');

Compute the date and time given a unix timestamp 1092941466.

SELECT datetime(1092941466,'unixepoch');

Compute the date and time given a unix timestamp 1092941466,and compensate for your local timezone.

Compute the current unix timestamp.

SELECT strftime('%s','now');

Compute the number of days since the signing of the US Declaration of Independence.

SELECT julianday('now') - julianday('1776-07-04');

Compute the number of seconds since a particular moment in 2004:

Compute the date of the first Tuesday in October for the current year.

Compute the time since the unix epoch in seconds (like strftime('%s','now') except includes fractional part):

SELECT (julianday('now') - 2440587.5)*86400.0;
@H_502_90@ 原文链接:https://www.f2er.com/sqlite/201478.html

猜你在找的Sqlite相关文章