Trim to date

2 minutes to read Download PDF Edit

Functions to round off dates to different time units.

trimToMinutes

Trim the date to minutes, rounding off all (milli)seconds to zero.

Input parameters

  • date that should be trimmed Type: DateTime

Output

The same date, only rounded down to minutes. Type: DateTime

(assume a variable $myDate that represents ‘08-06-2008 10:12:51’)

trimToMinutes($myDate)

returns:

'Sun Jun 08 10:12:00 CEST 2008'

trimToHours

Trim the date to hours, rounding off all minutes down to zero.

Input parameters

  • date that should be trimmed Type: DateTime

Output

The same date, only rounded down to hours. Type: DateTime

(assume a variable $myDate that represents ‘08-06-2008 10:12:51’)

trimToHours($myDate)

returns:

'Sun Jun 08 10:00:00 CEST 2008'

trimToDays

Trim the date to days, rounding off all hours to zero.

Input parameters

  • date that should be trimmed Type: DateTime

Output

The same date, only rounded down to days. Type: DateTime

(assume a variable $myDate that represents ‘08-06-2008 10:12:51’)

trimToDays($myDate)

returns:

'Sun Jun 08 00:00:00 CEST 2008'

trimToMonths

Trim the date to months, rounding off all days to zero.

Input parameters

  • date that should be trimmed Type: DateTime

Output

The same date, only rounded down to months. Type: DateTime

(assume a variable $myDate that represents ‘08-06-2008 10:12:51’)

trimToMonths($myDate)

returns:

'Sun Jun 01 00:00:00 CEST 2008'

trimToYears

Trim the date to years, rounding off all months, days to zero.

Input parameters

  • date that should be trimmed Type: DateTime

Output

The same date, only rounded down to years. Type: DateTime

(assume a variable $myDate that represents ‘08-06-2008 10:12:51’)

trimToYears($myDate)

returns:

'Tue Jan 08 00:00:00 CEST 2008'

Copyright © Mendix. All rights reserved. | Mendix.com | Terms of Use | Privacy Policy