"함수 now()"의 두 판 사이의 차이

65번째 줄: 65번째 줄:
[[분류:MySQL]]
[[분류:MySQL]]
<source lang='sql'>
<source lang='sql'>
select now();
SELECT NOW();
-- 2014-09-06 23:01:43
</source>
</source>
<source lang='sql'>
<source lang='sql'>
select sysdate();
SELECT SYSDATE();
-- 2014-09-06 23:01:43
</source>
</source>



2014년 9월 6일 (토) 23:02 판

  다른 뜻에 대해서는 함수 now (unixtime) 문서를 참조하십시오.
  다른 뜻에 대해서는 함수 now (iso8601) 문서를 참조하십시오.
  • example: 2011-01-01 21:00:00

1 Bash

NOW=`date +%Y-%m-%d\ %H:%M:%S`

2 C#

String now = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

3 CMD

set now=%date% %time%
echo %now%
REM 2012-08-24 15:00:22.05

4 Java

Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String now = sdf.format(date);
String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());

5 PHP

$now = date('Y-m-d H:i:s');

6 Python

import time
t = time.time()
now = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(t))
print( now )
# 2014-08-25 00:34:40

7 Ruby

puts Time.now.strftime "%Y-%m-%d %H:%M:%S"
# 2000-03-14 01:59:00
puts Time.new.strftime "%Y-%m-%d %H:%M:%S"
# 2000-03-14 01:59:00

8 SQL

8.1 MySQL

SELECT NOW();
-- 2014-09-06 23:01:43
SELECT SYSDATE();
-- 2014-09-06 23:01:43

8.2 Oracle

select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') as "Now" from dual;

8.3 PostgreSQL

SELECT CURRENT_TIMESTAMP;
SELECT LOCALTIMESTAMP;

9 같이 보기