ajay p
ajay p

Reputation: 669

MySQL format issue

I have a MySQL query:

SELECT DATE_FORMAT(CONVERT_TZ(`StartTime`, '+0:00', `timeZone`),'%b %d, %Y %h:%i %p') as start, 
       DATE_FORMAT(CONVERT_TZ(`endTime`, '+0:00', `timeZone`),'%b %d, %Y %h:%i %p') as end 

which is giving output as

start = Nov 09, 2015 06:40 PM
end = Nov 09, 2015 07:10 PM

But I want the output in following format: Nov 09, 2015 06:40 PM EST instead of Nov 09, 2015 06:40 PM

Upvotes: 1

Views: 23

Answers (1)

Sasha Pachev
Sasha Pachev

Reputation: 5326

Since you have the time zone already, you can just insert it into the second DATE_FORMAT() argument like this:

SELECT DATE_FORMAT(CONVERT_TZ(`StartTime`, '+0:00', `timeZone`),CONCAT'%b %d, %Y %h:%i %p ', timeZone)) as start, 
  DATE_FORMAT(CONVERT_TZ(`endTime`, '+0:00', `timeZone`), CONCAT('%b %d, %Y %h:%i %p ', timeZone)) as end
 FROM appointments
 WHERE CounselorID = 225 AND AvaliableStatus = '0' AND counselorsStatus = 0 AND Type = 2

Upvotes: 1

Related Questions