You are viewing content for 5.1 | 5.0 | 4.9 | 4.8 | 4.7 | 4.6 | 4.5 | 4.4 | 4.3 | Previous Releases


dateTrunc

Returns a date truncated so as to remove specified smaller units.

Example

Truncate the current time, setting hours to 0 (12am).

dateTrunc($currentTime, 'day')

Syntax

dateTrunc(date expr d, string part)
  • d : date value to truncate
  • part : string units to truncate d to

Returns

date

Notes

Returns to the rounded value of a timestamp to the interval needed according to part. Suppose $currenttime_ evaluates to 8/25/19 11:28:44 AM. Then, dateTrunc($currentTime, 'day') would return 8/25/19 12:00:00 AM.

Allowed values for part are:

  • millisecond
  • second
  • minute
  • hour
  • day
  • month
  • year

© Incorta, Inc. All Rights Reserved.