Cordova Javascript SQLite 按日期时间排序

Cordova Javascript SQLite Order By DateTime

如何select并使用日期时间进行排序?

我的查询:

SELECT id, title, note, lastUpdated, dateCreated FROM notes ORDER BY datetime(lastUpdated) DESC

我的table:

CREATE TABLE IF NOT EXISTS notes (
    id INTEGER PRIMARY KEY AUTOINCREMENT, 
    title TEXT NOT NULL, 
    note TEXT, 
    lastUpdated DATETIME,
    dateCreated DATETIME DEFAULT CURRENT_TIMESTAMP)`

我的插入:

INSERT INTO notes (
    title, note, lastUpdated) 
VALUES (?1,?2,?3)`, [$scope.note.title, $scope.note.note, new Date()]

我插入日期 javascript new Date().

如果我打印此 select 查询的结果:

SELECT id, title, note, lastUpdated, dateCreated FROM notes ORDER BY datetime(lastUpdated) DESC

结果看起来像这样:

dateCreated:'2021-01-17 09:24:13'
id:1
lastUpdated:'Mon Jan 18 2021 00:37:36 GMT-0700 (Mountain Standard Time)'
note:'Test'
title:'Title'

试试这个:

INSERT INTO notes (
    title, note, lastUpdated) 
VALUES (?1,?2,?3)`, [$scope.note.title, $scope.note.note, new Date().toISOString()]