Add current date and time into MYSQL database


You are building a Bank System? 
A cash payment service or user authentication system?


You will probably need to add current time and date in your MYSQL database to do so follow those steps.

Let say we want to create a little database in mysql for student with 4 columns:
id, name, age , dateEntry .

It will look just like this:

Create database student; use student;
Create table student (id int(11) NOT NULL AUTO_INCREMENT , name varchar(30) not null,  age date not null, dateEntry timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Show databases; 

Let's test it on MYSQL console

Let's insert some data in our database:

insert into student (name,age) values ("Jean Stanley","1999-12-12");








 N.B: 
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP  is the magical line that allow you to insert the current system date in your database make sure your system date is set Correctly.

Having questions? Feel free to comment this articles .

And do not forget to download our app to get update. Clic here: https://play.google.com/store/apps/details?id=jbej90.automation.test.haitiangeek


or Clic on the image to download the mobile app






Commentaires

Posts les plus consultés de ce blog

Men kijan pou voye MINUT NATCOM-NATCOM pou ZANMIW an 3 etap

Comment partager des minutes sur natcom

Men kijan pou prete kob, minutes, lajan nan men NATCOM Ayiti