Commit | Line | Data |
---|---|---|
ea8ea560 SBS |
1 | #!/bin/bash |
2 | ||
3 | # Desc: Template to display date and time. | |
4 | ||
5 | dateTimeShort(){ | |
6 | # Desc: Timestamp without separators (YYYYmmddTHHMMSS+zzzz) | |
7 | # Usage: dateTimeShort | |
903dce87 | 8 | # Version 1.0.0 |
ea8ea560 | 9 | # Output: stdout: timestamp (ISO-8601, no separators) |
b03c9c0c | 10 | local TIME_CURRENT TIME_CURRENT_SHORT |
ea8ea560 SBS |
11 | TIME_CURRENT="$(date --iso-8601=seconds)" ; # Produce `date`-parsable current timestamp with resolution of 1 second. |
12 | TIME_CURRENT_SHORT="$(date -d "$TIME_CURRENT" +%Y%m%dT%H%M%S%z)"; # Produce separator-less current timestamp with resolution 1 second. | |
13 | echo "$TIME_CURRENT_SHORT"; | |
0f48af59 | 14 | } # Get date&time without separators |
ea8ea560 SBS |
15 | |
16 | #==BEGIN sample code== | |
17 | echo "The current day and time is:$(dateTimeShort)" | |
18 | #==END sample code== | |
19 | ||
20 | # Author: Steven Baltakatei Sandoval | |
21 | # License: GPLv3+ |