Skip to main content
deleted 1 character in body
Source Link
Daniel Ballinger
  • 103k
  • 40
  • 275
  • 601

You can use the DateTime.format(String) method and as a Java SimpleDateFormat as the parameter.

System.debug(Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));

gives:

2015-05-12T15:43:36.358-0700

This will be for the current users local time zone. Note:

"If the time zone cannot be determined, GMT is used."

If you want more control over the timezone you can use the DateTime.format(String, String) method and specify the TimeZone.

You can use the DateTime.format(String) method and as a Java SimpleDateFormat.

System.debug(Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));

gives:

2015-05-12T15:43:36.358-0700

You can use the DateTime.format(String) method and a Java SimpleDateFormat as the parameter.

System.debug(Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));

gives:

2015-05-12T15:43:36.358-0700

This will be for the current users local time zone. Note:

"If the time zone cannot be determined, GMT is used."

If you want more control over the timezone you can use the DateTime.format(String, String) method and specify the TimeZone.

deleted 1 character in body
Source Link
Daniel Ballinger
  • 103k
  • 40
  • 275
  • 601

You can use the DateTime.format(String) method and assas a Java SimpleDateFormat.

System.debug(Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));

gives:

2015-05-12T15:43:36.358-0700

You can use the DateTime.format(String) method and ass a Java SimpleDateFormat.

You can use the DateTime.format(String) method and as a Java SimpleDateFormat.

System.debug(Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));

gives:

2015-05-12T15:43:36.358-0700

Source Link
Daniel Ballinger
  • 103k
  • 40
  • 275
  • 601

You can use the DateTime.format(String) method and ass a Java SimpleDateFormat.