Current Time Script
Jul 13, 2024
Current Time Script
This script returns the current date and time in the format date = "2024-07-13T14:27:45-06:00".
Prerequisites
- Bash shell
datecommand (available on most Unix-like systems)
Usage
-
Save the Script:
Save the following script to a file, e.g.,
current_time.sh:#!/bin/bash # Get the current date and time in the desired format current_time= # Format the time zone offset with a colon formatted_time=":" # Print the result -
Make the Script Executable:
Run the following command to make the script executable:
-
Run the Script:
Execute the script using the following command:
The output will be the current date and time in the specified format, e.g.:
date = "2024-07-13T14:27:45-06:00"
License
This script is provided as-is without any warranty. Feel free to modify and use it as needed.