title | url |
---|---|
Trim to Date |
/refguide7/trim-to-date/ |
These are functions to round off dates to different time units.
Trim the date to seconds, rounding off all milliseconds to zero.
- The date that should be trimmed
- Type: DateTime
- The same date, only rounded down to seconds
- Type: DateTime
Assume a variable $myDate
that represents '08-06-2008 10:12:51.387':
trimToSeconds($myDate)
returns:
'Sun Jun 08 10:12:51 CEST 2008'
Trim the date to minutes, rounding off all (milli)seconds to zero.
- The date that should be trimmed
- Type: DateTime
- 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'
Trim the date to hours, rounding off all minutes to zero.
trimToHours
uses the user's time zone, and trimToHoursUTC
uses the UTC time zone.
- The date that should be trimmed
- Type: DateTime
- 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'
Trim the date to days, rounding off all hours to zero.
trimToDays
uses the user's time zone, and trimToDaysUTC
uses the UTC time zone.
- The date that should be trimmed
- Type: DateTime
- 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'
Trim the date to months, rounding off all days to zero.
trimToMonths
uses the user's time zone and trimToMonthsUTC
uses the UTC time zone.
- date that should be trimmed
- Type: DateTime
- 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'
Trim the date to years, rounding off all months and days to zero.
trimToYears
uses the user's time zone, and trimToYearsUTC
uses the UTC time zone.
- The date that should be trimmed
- Type: DateTime
- 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 01 00:00:00 CEST 2008'