0

This command will output the following:
date --iso-8601=ns

2025-04-04T12:10:16,045431370+02:00

According to man date the ns is documented as follows:

-I[FMT], --iso-8601[=FMT]
output  date/time  in  ISO  8601  format.   FMT='date'  for  date  only  (the  default),  'hours',  'minutes',  'seconds',
or  'ns'  for  date and time to the indicated precision.

Confusing part is 'ns' for date and time to the indicated precision
What exactly is "indicated precision"? What is ns?

Particularly I want to know the meaning of number 045431370 in output of 2025-04-04T12:10:16,045431370+02:00

How to interpret 045431370 number? and what is ns option?

btw. I assume +02:00 means UTC offset? or UTC +2?

1 Answer 1

4

ns here is nanoseconds: the date and time are displayed at nanosecond precision (whether that’s accurate or not is a different question). Your date means April 4, 2025, at 12:10:16 (hours, minutes, seconds) and 45431370 nanoseconds, that is to say, 45 milliseconds, 431 microseconds, and 370 nanoseconds, two hours ahead of UTC (so the UTC time was 10:10:16).

The GNU date man page doesn’t explain this (it's just a stub derived from the output of date --help which much remains short) but the full manual, available in info/dvi/pdf/html format (same as can be found online at gnu.org for the latest version) does (see info -- ls --iso-8601 on a GNU system).

Instead of using the --iso-8601[=FMT] option, you can also specify the format manually with +format where you'll be able to use however much precision you need for the seconds part and change the decimal radix character from ,¹ to English-style . if you wish. For example:

$ date --iso-8601=ns; date +%FT%T.%4N%:z
2025-04-04T13:10:32,302352844+02:00
2025-04-04T13:10:32.3052+02:00

Here showing the seconds part (32.3052) with 4 digits after the period (10,000th of second)².

Note that none of --iso-8601, %N, %:z are standard nor portable.


¹ Comma is the decimal radix character as used in most non-English speaking parts of the world, and while ISO8601 allows both . and , for the second part, it says the , is preferred which is likely why GNU date chose , over . even though a lot of its other defaults are based on US English.

² Note that %xN (x defaulting to 9) is always 0-padded to x digits, so that one millisecond after midnight, date +%T.%3N will show 00:00:00.001 as you'd expect and not 00:00:00.1 which would be incorrect as meaning on decisecond after midnight.

2
  • I wish this to be explicitly said so in man date, so the 045431370 means 45 miliseconds, 431 microseconds and 370 nanoseconds? Commented Apr 4 at 10:40
  • 2
    That’s right. As is often the case for GNU programs, the man page isn’t as detailed as the info manual. Commented Apr 4 at 10:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.