- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set current date and time to timestamp in MySQL
152 Lectures 16 hours
87 Lectures 5.5 hours
Let us first create a table. One of the columns is set as TIMESTAMP −
mysql> create table DemoTable648( UserId int NOT NULL AUTO_INCREMENT,UserLoginTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,PRIMARYKEY(UserId) ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command. Here, we have set the current date and time to timestamp column using the NOW() method −
mysql> insert into DemoTable648(UserLoginTime) values(NOW()); Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable648;
This will produce the following output −
+--------+---------------------+ | UserId | UserLoginTime | +--------+---------------------+ | 1 | 2019-07-18 21:11:50 | +--------+---------------------+ 1 row in set (0.00 sec)
- How to update a Timestamp and set to current date in MongoDB?
- Python Pandas - Get the current date and time from Timestamp object
- MySQL - Insert current date/time?
- Display Timestamp before the current date in MySQL
- Combine date and time column into a timestamp in MySQL?
- Current Date and Time in Perl
- How to insert current date/time in MySQL?
- How to set default date time as system date time in MySQL?
- Java Program to Display current Date and Time
- MySQL query to insert current date plus specific time?
- Get current time and date on Android
- How to get current time and date in C++?
- How to get current date and time in Python?
- How to print current date and time using Python?