You need to use the date() function to format it as you want. The date function takes a string for the format as the first parameter and an optional timestamp parameter. You will need to convert your string date from MySQL into a timestamp using the strtotime function.
@PHPycho that will only work when dealing with dates generated by the php server. If the dates are entered into the MySQL server using the MySQL server time (such as NOW() in a SQL statement) then the time will be in that server’s timezone. If you are using a different timezone in your PHP app, and treating the times out of MySQL as if they were from the same timezone then you will have bugs galore.
That’s perfectly fine for you, as long as you keep to those rules - however your advise was based on rules that you hadn’t stated (such as only ever using the PHP server’s time).
It’s always safer to make sure mistakes can’t happen, and have everything running happily on the same timezone. If your php and db servers are at the same host it’s likely they’re set to the same timezone and you can just use PHP to figure out the current timezone, then alter all dates according to what timezone you want them to be in.
One simple Question:
Is there any effective method/techniques for dealing with timezone problems?
In my case, Since if you use only PHP’s there care should be taken (date should be fed from php to mysql). So i think this method may not be appropriate when you deal with NOW() or any other mysql date function in Query.