DateTime.getTimeZone()
Signature
String getTimeZone(DateTime date, boolean daylight_saving_name)
Description
Gets the timezone id from DateTime object.
Parameters
Name | Type | Description |
date | DateTime | A DateTime to get the timezone of. |
daylight_saving_name | boolean | If true returns the daylight savings name. |
Returns
Type | Description |
String | The timezone id. |
Example
DateTime dateNow = DateTime.now();
String tz = DateTime.getTimeZone(dateNow, false);
Result is:
tz contains: "America/Los_Angeles time" if the host you are running on is set to PST