How to change time format in Solaris-10?

Hi,
I want to change time format to AM/PM format. In below output -

-bash-3.2# date
Thu Jul 27 16:48:59 PDT 2017
-bash-3.2#

I want to be it 4:48:59 PM. NTP is configured on this. Can time format be changed while NTP server is configured ?
Thanks

Have you looked at the options for the date command? You can build almost any format you can think of with the options there. Are there certain options that are not working for you? As an example, you could:-

date '+%Y%m%d%H%M%S'          # Output in a sortable format, yet still obvious to a human reader
date '+%s'                    # Number of seconds since the Epoch

NTP is not a problem for you. The NTP process manages the system clock, which is not what you see when you use the date command. The system clock is held in seconds from the epoch (or parts of) and the date command reads the system clock, displaying it according to your defined time zone in the format you have specified, or the default if you do not set one. Although the date command reads (or writes) the clock, there is no active relationship between them.

Robin

To add to what Robin already said: time is stored in UNIX systems not in a certain format, but a number: the so-called "UNIX time", which counts the seconds since Midnight Jan 1st, 1970. As the time of writing this number is: 1501232481.

Whatever output the date -command (and the system calls it implements) delivers, it is always this number, calculated into a date and then formatted somehow. Therefore a "UNIX-date-format" doesn't exist: the date information is always formatted on the fly to the respective specification (like, as Robin said, the option to the date -command).

I hope this helps.

bakunin

1 Like

Thanks. I did some more digging and found "LC_TIME=en_US.ISO8859-1" was set in profile, which was converting format.