Created
May 24, 2023 23:08
-
-
Save jflopezfernandez/8567afc2954e7e1e9194a9d1ba934a57 to your computer and use it in GitHub Desktop.
This bash script outputs a timestamp of the current time useful for time-dependent filenames, logging statements. etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# | |
# This function is meant to be defined or included in a file automatically | |
# sourced by the shell on startup, such as the ~/.bashrc file. | |
# | |
# Once this function is sourced, it can be called like any other bash function, | |
# and the output looks something like the following. | |
# | |
# 2023-05-24-18:03:09.368078818 | |
# | |
# TODO(jflopez): Print the timestamp using the current locale's timezone. | |
function timestamp() { | |
date "+%Y-%m-%d-%H:%M:%S.%N" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment