Date Handling in the SoftLayer API
From SoftLayer Development Network Wiki
Most of the data presented in the SoftLayer API is date-sensitive. Servers have provision dates, tickets have modify dates, and nearly everything has a creation date. To maintain standards compliancy and consistency for all of our users worldwide, SoftLayer presents its dates in ISO 8601 format under the data type dateTime. ISO 8601 represents a complete date including day, time, and timezone. Every data type property in the SoftLayer API that ends with the string "Date" is represented by the dateTime format.
Contents |
The dateTime Datatype
The dateTime data type uses the following format:
<YYYY>-<MM>-<DD>T<HH>:<MM>:<SS>-<TZ>
With the following values:
- YYYY: A 4-digit representation of the year.
- MM: A 2-digit representation of the month, including a leading zero if applicable.
- DD: A 2-digit representation of the day, including a leading zero if applicable.
- HH: A 2-digit representation of the hour in 24-hour format, including a leading zero if applicable.
- MM: A 2-digit representation of the minute, including a leading zero if applicable.
- SS: A 2-digit representation of the second, including a leading zero if applicable.
- TZ: The time zone represented as the difference between the current time zone from GMT in HH:MM format.
For example the dateTime value 2007-07-19T15:21:48-05:00 has the following real-world value:
- Year 2007
- Month 7 (July)
- Day 19
- 15th hour (3pm)
- Minute 21
- 48 seconds
- Timezone GMT-0500 (PST)
Setting Your Timezone
If your API calls return incorrect times for your location then you likely need to set the time zone for the user making your API calls. To set your user's time zone via the portal:
- Log into our customer portal with your API user's username and portal password.
- Click the administrative link then click on your username in the resulting user list.
- Locate the Time Zone dropdown list on this page, select your time zone, then click the Edit User Profile button.
To set your user's time zone via direct API call invoke the editObject method in the SoftLayer_User_Customer service, setting the timeZoneId property in the template object passed to the call. You can retrieve a list of time zones from the getAllObjects method in the SoftLayer_Locale_Timezone service.
Associated Methods
- SoftLayer_User_Customer::getTimezone
- SoftLayer_User_Customer::editObject
- SoftLayer_Locale_Timezone::getAllObjects

