On UNIX-y systems, this is the last time that a file's status was changed. This is not the creation time. A lot of people (freshmen) seem to read the stat manpage and miss this small, but vital, fact when programming.

Compare with atime and mtime.

It's also a libc function that converts a time_t pointer to an ASCII date and time. Calling functions should copy the string into its own buffer, as the static data will be overwritten with each ctime() call.

As eric+ says, ctime is short for change time, or st_ctime from the stat structure. What he doesn't say, is that it is attribute change time, not file content change--that's mtime.

Any system call that modifies a file's inode will update the ctime. This does include chmod and utime but not read or write.

The -c option of the ls command causes ls to use the ctime (instead of the default of mtime) when sorting by (-t) or displaying (-l) the time.

Note that of the three times listed in the stat structure, ctime is the only one that can't be set by a standard system call. (You can change it to the current time, but you can't set it.)


The ctime libc function returns a character representation of a given unix time. Not only does the ctime function use a static buffer, but it also uses a static format. For more flexible time formatting, try strftime which uses a printf style format string, and since you supply the buffer, it is even thread safe!

Log in or register to write something here or to contact authors.