Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling Date from MySQL Database Remove Time

Tags:

sql

php

I am pulling the value EventDate from a table called events. At the moment is giving me a timestamp along with the date - 2012-05-29 00:00:00.

Is there anyway to trim this in PHP?

like image 759
user1371500 Avatar asked May 26 '26 14:05

user1371500


1 Answers

Try using MySQL's build in functions such as DATE_FORMAT() or even DATE()

SELECT
  DATE_FORMAT(EventDate, '%Y-%m-%d') AS eventDate
FROM events;

 

SELECT
  DATE(EventDate) AS eventDate
FROM events;
like image 170
Jacco Avatar answered May 30 '26 02:05

Jacco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!