Get Date And Time

Submitted by:Andery Smith

Date added:09 October, 2011

Category:MySQL

Example shows how to get the database date and time.

Tags: get date , get time

Code Snippet:

-- Simple example
SELECT NOW()

-- Formatted date example
SELECT DATE_FORMAT(NOW(),'%W %e, %M, %Y') AS FORMATTED_DATE

-- Get only date with curdate()
SELECT CURDATE()

-- Get formatted curdate()
SELECT DATE_FORMAT(CURDATE(), '%D %M %Y')

-- Get only time with curtime()
SELECT CURTIME()
 
 

Comments