함수 now()

Jmnote (토론 | 기여)님의 2014년 6월 3일 (화) 21:52 판 (→‎cmd)
  • 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 SQL

6.1 MySQL

select now();
select sysdate();

6.2 Oracle

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

6.3 PostgreSQL

SELECT CURRENT_TIMESTAMP;
SELECT LOCALTIMESTAMP;

7 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}