MySQL query timestamp (TIMESTAMP) converted to common readable time format

Source: Internet
Author: User
Tags local time modifiers month name mysql query readable

From_unixtime () is the time function in MySQL
Date is the parameter that needs to be processed (the parameter is a UNIX timestamp), can be a field name, or it can be a Unix timestamp string
The following '%y%m%d ' is primarily the formatting of the return value
For example:

 mysql>  select  From_unixtime ( Span style= "color: #800000; Font-weight:bold; " >1249488000 ,  %y%m%d   '   '  ->  20071120   MySQL  >  select  from_unixtime (1249488000 ,  '  

If no parameter is called, returns a Unix timestamp (the number of seconds after the ' 1970-01-01 00:00:00 ' GMT) as an unsigned integer. If you call Unix_timestamp () with date, it returns the value of the parameter in the form of a number of seconds after the ' 1970-01-01 00:00:00 ' GMT. Date can be a date string, a DateTime string, a timestamp, or a number in the YYMMDD or YYYMMDD format of a local time.

For example:

Mysql> SELECTUnix_timestamp (); (Execution makes time: the- ,- . Ten:Ten: +) -1249524739MySQL> SELECTUnix_timestamp ('2009-08-06') ;  -1249488000 
Use the From_unixtime function, as follows: 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-month name (January ... December)%W-week name (Sunday ... Saturday)%D The date of the month with English prefixes (1st, 2nd, 3rd, etc.). )%Y years, numbers,4bit%Y years, numbers,2bit%a abbreviated weekday name (Sun ... Sat)%Number of days in the D-month, number (xx...... to)   %Number of days in the E-month, number (0...... to)   %M-month, number ( on...... A)   %C Month, number (1...... A)   %b Abbreviated month name (Jan ...Dec)   %J Number of Days in a year (001......366)   %H Hours (xx...... at)   %K Hours (0...... at)   %H Hours ( on...... A)   %I-Hour ( on...... A)   %L Hours (1...... A)   %I minute, number (xx...... -)   %R time, AHours (hh:mm:ss[AP]M)%T time, -hours (HH:MM:SS)%s seconds (xx...... -)   %s seconds (xx...... -)   %P AM or PM%W one days in the week (0=Sunday ...6=Saturday)%U Week (0...... the), here Sunday is the first day of the week%U Week (0...... the), here Monday is the first day of the week%%A text "%”。

MySQL query timestamp (TIMESTAMP) converted to common readable time format

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.