Java reads json data to MySQL. The value of regist_time in json is String and the value of Date in the database. if the value of regist_time is null, the database cannot be inserted. If all regist_time values are NULL, if (regist_time & quot;)
Returns the date-related Now () | CURRENT_TIMESTAMP (); returns the current time to_days (date). returns the date value of the date value from the date of the year to date (not counted before January 1, 1582) convert to days date is the DATE type
This article describes how to set the time zone of Linux PHP MySQL. I hope this method will be helpful to you.
In the LAMP environment, it is ideal that the time zones of Linux PHP MySQL are set to the same. Otherwise, the program will easily
One, time lag
DateDiff: To put it bluntly is to use the first time to reduce the second time, the order can not forget
The code is as follows
Copy Code
Select DateDiff (' 2012-08-08 ', ' 2012-08-13 '); ---5
The Date_add () function in MySQL1. Definition: The function adds the specified time interval to the date.2. Syntax: Date_add (date,interval expr type) The date parameter is a valid day expression. The expr parameter is the time interval that you
This article for Bo Master original, without permission not reproduced:When writing SQL, you often have to pass the value time in SQL, calculate and filter the time. Before the time is calculated in the background, direct value to SQL,Today we found
Reprint please indicate source: http://blog.csdn.net/zhaoyanjun6/article/details/80393761This article is from "Zhaoyan's blog"
Get current time
Return current Date: select Curdate ();
2018-05-21
Return current time:
TIMESTAMP4 bytes of storage; values are saved in UTC format;. Time zone conversion, which transforms the current time zone when it is stored, and then converts it back to the current time zone.Datetime8 bytes stored, actual format stored, time-zone
PHP script side of the urban settings can be set under the PHP.ini date.timezone key value of ' Asia/shanghai ' can be. Typically, however, the shared virtual host itself does not modify php.ini permissions. This time it should be added to the
The easiest way to do it
The code is as follows
Copy Code
Select To_days (str_to_date (' 12/1/2001 12:00:00 AM ', '%m/%d/%y '))-To_days (Str_to_date (' 11/28/2001 12:00:00 AM ', '%m/%d/%y ')) as a from table1
The Mktime function in PHP is queried by time, in fact, in addition to this solution, there are also functions specifically for date and time in MySQL, including date (), Date_add (), Date_sub (), Date_format (), and so on.
The code is
DayOfWeek (date)
Returns the week index of date (1= Sunday, 2 = Monday, ...). 7= Saturday). These index values correspond to ODBC standards.Mysql> Select DayOfWeek (' 1998-02-03 ');-> 3
Weekday (date)Returns the week index of date (0= Monday, 1 =
The correct PHP SQL statement should be written as:
The code is as follows
Copy Code
$sql = "INSERT into table (datetime) VALUES ('". Date ("Y-m-d h:i:s", Time ()). The DateTime field is of type DateTime,
Let's look at an example:Select Now (), now () +0;You can see that the now () function can return a time or return a number to see how you use it. If you increase or decrease relative to the current time, you cannot add or subtract a number directly
Two ways, one is to intercept when the database is queried, and the other is to intercept when it is used.1. DatabaseSelect Date_format (Date field, '%y-%m-%d ') as ' date ' from test2.java ProgramSimpleDateFormat DATEFM = new SimpleDateFormat
Timestamp function: Current_timestamp ()Add a timestamp function at this location.And then the whole thing is this:Update based on current timestamp there is no tick will determine what time your time is (one is the time the data is written, one
MySQL Time type: DATETIME & TIMESTAMP
Length
The datetime type contains date and time, range 1000-01-01 00:00:00 ~ 9999-12-31 23:59:59. DateTime can also contain milliseconds, for example, 2018-03-11 14::13:22.999
Timestamp can
The following is a reprint of the MySQL millisecond, microsecond precision time processing two paragraphs, left for themselves and for everyone to reference ~ ~MySQL gets milliseconds, microseconds, and milliseconds, microseconds processingMySQL
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.