1.MySQL
SELECT DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s');
2.Oracle
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
3.Java
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
System.out.println("当前时间:" + sdf.format(date));
}
}
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10