mysql format date
DATE_FORMAT(date, format)
-- E.g.
SELECT DATE_FORMAT(dateField, '%m/%d/%Y') FROM TableName;
-- See https://www.mysqltutorial.org/mysql-date_format/ for available formats
mysql format date
DATE_FORMAT(date, format)
-- E.g.
SELECT DATE_FORMAT(dateField, '%m/%d/%Y') FROM TableName;
-- See https://www.mysqltutorial.org/mysql-date_format/ for available formats
mysql timestamp to date
-- Use the FROM_UNIXTIME() function in MySQL
select from_unixtime(timestamp) from my_tbl;
mysql date format
-- Converts 'dd.mm.yyyy' to date (my_date_col is VARCHAR)
SELECT STR_TO_DATE(my_date_col,'%d.%m.%Y') AS my_strdate FROM my_table;
-- Converts 'dd.mm.yyyy' to 'YYYY-MM-DD'
SELECT DATE_FORMAT(STR_TO_DATE(my_date_col,'%d.%m.%Y'), '%Y-%m-%d') AS my_strdate
FROM my_table;
format time mysql
-- use DATE_FORMAT with %H %i
-- SELECT DATE_FORMAT(MemberBookFacility.time, '%H:%i')
"45": "09:00",
"24": "10:00",
"42": "11:00",
"48": "12:00",
-- ONcakephp must use below format
$this->virtualFields['time'] = "DATE_FORMAT(MemberBookFacility.time, '%H:%i')"; // using this for use concat
return $this->find('list', array(
'conditions' => $conditions,
'fields' => array(
'MemberBookFacility.id',
'time',
),
'order' => array(
'MemberBookFacility.time ASC',
),
));
MySQL datetime format
use \Datetime;
$now = new DateTime();
echo $now->format('Y-m-d H:i:s'); // MySQL datetime format
echo $now->getTimestamp(); // Unix Timestamp -- Since PHP 5.3
date format mysql
DECLARE df VARCHAR(20);
DECLARE dt VARCHAR(20);
SET df = DATE_FORMAT(_Datefrom,'%Y-%m-%d 00:00:00');
SET dt = DATE_FORMAT(_DateTo,'%Y-%m-%d 23:59:59');
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us