ctime

formats and displays dates 

Command


SYNOPSIS

ctime [-g|-l] [-f format | -t] [seconds]


DESCRIPTION

The ctime utility formats and displays dates. The date to be formatted is specified as seconds, the number of seconds since midnight on January 1, 1970 UTC (Coordinated Universal Time, also known as Greenwich Mean Time or GMT). If the seconds argument is not specified, the current date and time is displayed. ctime displays the formatted date and time in the local time zone.

The valid input range is from 0 which yields January 1, 1970 00:00 UTC to 4294967295 which yields February 6, 2106 06:28:15 UTC. Note that very small numbers are invalid in timezones west of UTC (GMT). For example, in EST -0500, the minimum value allowed is 18000 which equals five hours of offset multiplied by 3600 seconds per hour and yields January 1, 1970 00:00 EST. The error Bad number of seconds since the epoch is given for numbers out of range.

The time is displayed using the format specified by the -f or -t options. If neither of these options is specified, ctime uses a default format of "%a %b %e %H:%M:%S %Y" is used.

The format specifiers are the same as used by the date utility.

Options

-f format 

specifies a format string to be used when displaying the date. The format string uses the same format specifiers as the date utility.

The -f and -t options are mutually exclusive.

-g 

displays the time as Coordinated Universal Time (UTC). This is the same as Greenwich Mean Time (GMT).

The -g and -l options are mutually exclusive.

-l 

displays the time using the local time zone.

The -g and -l options are mutually exclusive.

-t 

displays the date and time using a format compatible with the -t option of touch. This is equivalent to specifying -f %C%y%m%d%H%M.%S

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:
cdate, date


PTC MKS Toolkit 10.5 Documentation Build 40.