Label:The solution is based on the following URL:http://blog.csdn.net/stail111/article/details/5640109Questions: MySQL database, if the date character blank in the database is a value of ' 0000-00-00 00:00:00 ' when queried, return: Cannot convert value ' 0000-00-00 00:00:00 ' from column TIMESTAMPWorkaround:Change the way you connect to a databaseAdd a parameter after the connection: Jdbc:mysql://127.0.0.1:3306/test Zerodatetimebehavior=converttonull
The display format of the same TIMESTAMP column is the same as that of the DATETIME column. In other words, the display width is fixed to 19 characters and the format is YYYY-MM-DDHH: MM: SS. Different ranges of datetime are retrieved and displayed in YYYY-MM-DDHH: MM: SS format. Supported range: 1000-01-0100:00:00 to 9999-12-3123: 59: 59 T
The display format of the same TIMESTAMP column is the same as that
When creating a table, if a field type in the table is TIMESTAMP, the default generation statement of this field is: CREATETABLE 'test' ('id' int (11) DEFAULTNULL, 'ctime' timestampNOTNULLDEFAULTCURRENT _ TIMESTAMPON when creating a table, if the table has a field type of TIMESTAMP, the default statement for generating this field is:
CREATE TABLE `test` ( `id` int(11) DEFAULT NULL, `ctime`
Tags: sel action string formatting text marker format entry users stringFunction: From_unixtimeEffect: Displays the time in MySQL as an int (11) in the "YYYY-MM-DD" format.Syntax:from_unixtime (Unix_timestamp,format)Returns a String representing the Unix time token, formatted according to the format string. FORMAT can contain the same modifiers as the entries listed in the Date_format () function.Formats the date value according to the format string.T
Code:SELECT FROM_UNIXTIME(1234567890, ‘%Y-%m-%d %H:%i:%S‘)Report:In MySQL, the storage type of a time field is int (11), and how to convert it into a character type, for example, stored as 13270655222, needs to be converted into YYYY-MM-DD form.Use the From_unixtime function, as follows:Code:FROM_UNIXTIME(unix_timestamp,format)Returns a String representing the Unix time token, formatted according to the format string. FORMAT can contain the same modif
function: from_unixtime function: mysql with int ( One) The time stored is "YYYY-Mm-DD "format to display. Syntax: From_unixtime (Unix_timestamp,format) returns a String representing the Unix time tag, formatted according to the format string. FORMAT can contain the same modifiers as the entries listed in the Date_format () function. Formats the date value according to the format string. The following modifiers can be used in the format string:%M-mont
MySQL is used to represent the time of the three types of date, DateTime, timestamp (if the int is counted, four kinds) is more easily confused, the following comparison of these three types of similarities and differencesSame pointCan be used to represent timeare presented as stringsDifferent points1. As the name implies, date only represents the ' yyyy-mm-dd ' form of the dates, DateTime represents the '
Valid mysql timestamp range
Things
From_unixtime/unix_timestamp overflow, unavailable
Cause
The number of seconds since returned by from_unixtime is the result of int type, and the valid range of int Is [-2 ^ 31 + 1, 2 ^ 31-1], that is, [-2147483648,214 7483648], 2147483648/365/24/3600 is converted to an adult for more than 68 years, and the maximum validity period is one day on January 1, 2
//time stamp Turn time functionRiqi (SJ) {varnow =New Date(sj*1000); varYear=now.getFullYear (); varMonth=now.getmonth (+1); var Date=now.getDate(); varHour=now.getHours (); varMinute=now.getminutes (); varSecond=now.getseconds (); returnyear+ "-" +month+ "-" +Date+ "+hour+": "+minute+": "+second; }You need the conversion to call the method:Riqi (time);The returned format is:2016-10-12 10:10:50JS timestamp format Date time due to the storage time
reprinted from Http://blog.csdn.net/ghsau. MySQL upgrade from 5.5 to 5.6,timestamp changesThe behavior of timestamp in MySQL5.5
The first timestamp non-null character De Yin default value is not set by default:Current_timestamp on UPDATE Current_timestamp
The default value of the
Tags: timestampObjectiveSome time ago, the system MySQL upgrade from 5.5 to 5.6, the system has a large number of anomalies. Most of the anomalies are caused by changes in timestamp behavior.The behavior of timestamp in MySQL5.5
The first timestamp non-null character De Yin default value is not set by default:
Label: usually storage time with datetime type, and now many systems also use int storage time, what difference do they have?
Individuals prefer to use int this is good for date calculations, so let's look at the kind of things that would be better. int(1). 4 bytes of storage, the length of int is 4 bytes, storage space is less than datatime, int index storage space is relatively small, sorting and query efficiency is relatively high a little (2very poor readability, unable to visually see the
I have not studied MySql in depth and have little basic knowledge. I can only use a manual when I encounter any problems. It seems that I have to arrange MySQL learning into a timetable.
Function: from_unixtimePurpose: display the time stored in int (11) in MySQL in the "YYYY-MM-DD" format.Syntax:From_unixtime (unix_timestamp, Format)
Returns a string representin
DATETIMEType is used when you need to include the date and time information at the same time. MySQL retrieves and displays DATETIME values in 'yyyy-MM-DD HH: MM: ss' format, the supported range is '2017-01-01 00:00:00 'to '2017-12-31 23:59:59 '. ("Supported" means that although earlier values may work, they cannot be guaranteed .)
DATEType is used when you only need a date value and there is no time section. MySQ
Store time stamp to MySQL database, use conversion function Unix_timestamp.
Pgsql
The code is as follows
Copy Code
INSERT into Tbl_name (col1) VALUES (Unix_timestamp (' 2012-11-13 13:54:22 '));1 INSERT into Tbl_name (col1) VALUES (Unix_timestamp (' 2012-11-13 13:54:22 '));
Another conversion function: From_unixtime, which is to turn the timestamp into a regular time f
time zone (East Zone 9, Japan time zone). 3. Display the inserted data again, changed, timestamp type of data increased by 1 hours Next discuss some of the other properties of timestamp 1.null is empty Timestamp default allows for "non-null" (NOT NULL by default), if you are in the definition "TS timestamp default NUL
Use execl to convert TimestampThe formula is:
Code :
= (Xxxxxxxxxx + 8*3600)/86400 + 70*365 + 19
Use a MySQL statement to explain the timestampSyntax example:
Code:
Select from_unixtime (1234567890, '% Y-% m-% d % H: % I: % s ')
Appendix:In MySQL, the storage type of a time field is int (11). How can it be converted to the character type? For example, if the storage is 13270655222, it must be con
Function: FROM_UNIXTIMEPurpose: display the time stored in INT (11) in MYSQL in the "YYYY-MM-DD" format.Syntax:FROM_UNIXTIME (unix_timestamp, format)
Returns a string representing the Unix time mark, formatted according to the format string. Format can contain the same modifier as the entries listed by the DATE_FORMAT () function.
Format the date value based on the format string.The following modifiers can be used in a format string:
% M month name (J
Function: FROM_UNIXTIMEPurpose: display the time stored in INT (11) in MYSQL in the "YYYY-MM-DD" format.Syntax:FROM_UNIXTIME (unix_timestamp, format)
Returns a string representing the Unix time mark, formatted according to the format string. Format can contain the same modifier as the entries listed by the DATE_FORMAT () function.
Format the date value based on the format string.The following modifiers can be used in a format string:
% M month name (J
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.