Format date
From FVue
Contents
yyyy-mm-dd hh:mm:ss
Bash
date '+%Y-%m-%d %H:%M:%S %z' date '+%Y%m%d-%H%M%S %z'
See: man date
PHP
date()
date('Y-m-d H:i:s');
DateTime::format()
$date = new DateTime();
print $date->format('Y-m-d H:i:s');
See also: http://www.php.net/manual/en/function.date.php
strftime()
strftime('%Y-%m-%d %H:%M:%S');
strftime('%F %T');
See also: http://www.php.net/manual/en/function.strftime.php
Pear::Date
Date->format('%Y-%m-%d %H:%M:%S');
See also: http://pear.php.net/package/Date/docs/latest/Date/Date.html#methodformat
PostgreSql
TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') -- Suppress padding blanks and zeroes for MM & DD TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-FMMM-FMDD HH24:MI:SS')
See also: http://www.postgresql.org/docs/7.4/interactive/functions-formatting.html
Ruby
require 'date'
DateTime.now.strftime('%Y-%m-%d %H:%M:%S')
DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%L') # With milliseconds
See: http://apidock.com/ruby/DateTime/strftime
Time.now.iso8601 # "2024-06-17T15:09:10+02:00"
Advertisement