re1man
re1man

Reputation: 2367

current_timestamp only get year, month, and day

I have an sql query that gets the current timestamp but it gets the entire timestamp and renders it via php. I was wondering how I could only get the year, month, and day and in this format : (month/day/year)

query :

SELECT badge_id, merchant_id, quest_title, quest_price, quest_date, quest_points 
FROM quests WHERE quest_id = $id

Upvotes: 0

Views: 1999

Answers (2)

Marc B
Marc B

Reputation: 360782

As per http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format

SELECT DATE_FORMAT('(%m/%d/%Y)', now()) AS datestring

Upvotes: 2

rodneyrehm
rodneyrehm

Reputation: 13557

Have a look at strtotime() and date()

<?php
echo date('m/d/Y', strtotime("2011-10-25 00:11:22"));

Upvotes: 0

Related Questions