Shardul Pendse
Shardul Pendse

Reputation: 304

Convert simple date into SQLite datetime format?

I have date in new Date() format. I need to convert to SQLite date time format.(2014-01-05T00:00:00.000Z). Is it possible to do so??

var  date = new Date();

now I need to convert this date to SQLite datetime format like (2014-01-05T00:00:00.000Z).

Upvotes: 4

Views: 10601

Answers (3)

Aditya Ponkshe
Aditya Ponkshe

Reputation: 3890

Use this

// Create an instance of the Date class
var date = new Date();

// Convert it to an ISO string
var sqliteDate = Date.toISOString();

take a look at this W3schools

Upvotes: 4

Web User
Web User

Reputation: 330

Try:

var date = new Date();
var sqllite_date = date.toISOString();

Upvotes: 15

Avinash Babu
Avinash Babu

Reputation: 6252

You can use strftime, from date and time functions.

SELECT strftime('%d-%m-%Y', 'now')

Output

10-06-2010

Hope this helps ..:)

Upvotes: -2

Related Questions