mysql>select now();
+---------------------+ |
now() | +---------------------+
| 2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)
mysql>select sysdate();
+---------------------+ | sysdate() | +---------------------+ |2011-06-11 12:00:54 | +---------------------+ 1 row in set (0.00 sec)
mysql>select curdate(); +------------+ | curdate() | +------------+ |2011-06-11 | +------------+ 1 row in set (0.00 sec)
mysql> select current_date; +--------------+ | current_date | +--------------+ |2011-06-11 | +--------------+ 1 row in set (0.00 sec)
mysql> select curtime(); +-----------+ | curtime() | +-----------+ | 12:00:54 | +-----------+ 1 row in set (0.00 sec)
mysql>select current_time; +--------------+ | current_time | +--------------+ |12:00:54 | +--------------+ 1 row in set (0.00 sec)
2. mysql (unix 時間戳、日期)轉換函式:
unix_timestamp(),unix_timestamp(date),from_unixtime(unix_timestamp),from_unixtime(unix_timestamp,format)
下面是示例:
select unix_timestamp(); -- 1218290027 ===得到當前時間的unix時間值
將具體時間來轉換成timestamp
select unix_timestamp('2008-08-08'); -- 1218124800select unix_timestamp('2008-08-08 12:30:00'); -- 1218169800
將timestamp來轉換成具體時間select from_unixtime(1218290027); -- '2008-08-09 21:53:47'select from_unixtime(1218124800); -- '2008-08-08 00:00:00'select from_unixtime(1218169800); -- '2008-08-08 12:30:00'
select from_unixtime(1218169800, '%y %d %m %h:%i:%s %x'); -- '2008 8th august 12:30:00 2008'
獲取系統時間及格式
datetime 數字型 system.datetime currenttime new system.datetime 取當前年月日時分秒 currenttime system.datetime.now 取當前年 int 年 currenttime.year 取當前月 int 月 currentt...
mysql 獲取系統時間
mysql select now now 2011 06 11 12 00 54 1 row in set 0.00 sec mysql select sysdate sysdate 2011 06 11 12 00 54 1 row in set 0.00 sec mysql select cur...
MySql獲取系統時間
mysql獲取系統當前時間的函式 環境 mysql server 5.1 問題 mysql獲取系統當前時間的函式 解決 now 函式以 yyyy mm dd hh mm ss 返回當前的日期時間,可以直接存到datetime欄位中。curdate 以 yyyy mm dd 的格式返回今天的日期,可以...