Search In This Blog

2016-09-06

How to get time in Salesforce?

There are a few way to get time.
1. Date.today()
  Returns the current date in the current user's time zone.
  Return Type: Date
  More info:Date Class

2. System.now()
  Returns the current date and time in the GMT time zone.
  Return Type: Datetime
  More info:System Class

3. datetime.now()
  Returns the current Datetime based on a GMT calendar.
  Return Type: Datetime
  The format of the returned datetime is: 'MM/DD/YYYY HH:MM PERIOD'
  More info: Datetime Class

4.datetime.now().time()
  Returns the current time based on a GMT calendar.
  Return Type: Time
  The format of the returned time is: 'HH:MM PERIOD'

5.datetime.now().getTime()
  Returns the current time from 1970/1/1.
  Return Type: Integer

6.NOW()
  Returns the current Datetime based on a GMT calendar.
  Return Type: Datetime


No comments:

Post a Comment