cdate

converts dates to seconds since January 1, 1970 

Command


SYNOPSIS

cdate [-f format] [datestring]

cdate -t time


DESCRIPTION

The cdate utility converts a date and time to the number of seconds since midnight on January 1, 1970 UTC (Coordinated Universal Time, also known as Greenwich Mean Time or GMT). The valid range of dates and times that can be specified is from January 1, 1970 00:00 UTC to December 31, 2190 23:59 UTC. Because the specified date and time are assumed to be in the local time zone, the actual valid dates range may differ depending on the offset from UTC. For example, EST (Eastern Standard Time) is 5 hours earlier than UTC, so the valid date and time range for that zone is December 31, 1969 19:00 EST to December 31, 2190 18:59 EST. Similarly, the earliest valid date and time for time zones east of UTC, will be January 1, 1970 00+offset:00 where offset is the offset from UTC. The error Bad date conversion is given for dates and times out of the valid range.

When using the first form of the command, the date to be converted is specified as datestring in a format specified by the -f option. If the -f option is not specified, datestring is assumed to be in the format "%a %b %e %H:%M:%S %Y" (using the same format specifiers as the date utility). If datestring is not specified, the current date and time is converted.

Options

-f format 

specifies a format string to be used when specifying the date and time to be converted. The format string uses the same format specifiers as the date utility. At a minimum, the format string must include a minimum of the year, month, day, hour, and minutes. Day of the week and seconds are optional.

Note:

The format specifiers %Z and %z are not supported by the cdate and result in an error if used.

The -f and -t options are mutually exclusive.

-t time 

specifies a particular time using the format:

[[[[cc]yy]MM]dd]hhmm[.ss]

where cc is the optional first 2 digits of the year, yy is the optional last 2 digits of the year, MM is the optional number of the month (01-12), dd is the optional day of the month, hh is the hour in 24 hour format (required), mm is the minutes (required), ss is the optional seconds.

The -f and -t options are mutually exclusive.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

An error occurred.

2 

A usage error occurred.


PORTABILITY

Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. Windows Server 2025.


AVAILABILITY

PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
ctime, date


PTC MKS Toolkit 10.5 Documentation Build 40.