SQLite inserts the current date time

Source: Internet
Author: User
Tags local time sqlite sqlite database

Just like when you commit the log, the system will record the time of the commit, if you want to insert data in the table created under Sqlite3, the time point of inserting data is stored in the SQLite database how to deal with it?

Create a database, such as Foo.db

Create a table in this list:

CREATE TABLE time ([ID] INTEGER PRIMARY Key,[idcardno] VARCHAR ([createdtime] TimeStamp not NULL DEFAULT current_timest AMP);

Insert data:

INSERT into time ([Idcardno]) VALUES (' AAA ');

View:

SELECT * from time;

The result is

1|aaa|2011-10-6 06:48:51

This time will find that this is not the time of the system, and the world time, how to deal with it?

CREATE TABLE time ([ID] INTEGER PRIMARY Key,[idcardno] VARCHAR ([createdtime] TimeStamp not NULL DEFAULT ("Now ', ' localtime '));

Insert Data again

INSERT into time ([Idcardno]) VALUES (' AAA ');

View:

1|aaa|2011-10-6 13:05:51

This corresponds to the local time of the system.

SQLite inserts the current date time

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.