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 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 year, number, 4 bit
%y year, number, 2 bit
%a abbreviated weekday name (Sun ... Sat)
Number of days in the month of%d, number (00 ...). 31)
Number of days in%e month, number (0 ... 31)
%m Month, number (01 ... 02H
%c month, number (1 ... 02H
%b Abbreviated month name (Jan ... DEC)
%j Days of the year (001 ... 366)
%H hours (00 ... 23)
%k hours (0 ... 23)
%h hours (01 ... 02H
%I Hours (01 ... 02H
%l hours (1 ... 02H
%i minutes, Numbers (00 ... 59)
%r time, 12 hours (Hh:mm:ss [ap]m)
%T time, 24 hours (HH:MM:SS)
%s seconds (00 ... 59)
%s seconds (00 ... 59)
%p am or PM
%w days in one weeks (0=sunday ... 6=saturday)
%u Week (0 ... 52), here Sunday is the first day of the week
%u Week (0 ... 52), here Monday is the first day of the week
Percent of a text "%".
--eof--
MySQL timestamp converted to readable time format