Bash Script for Current Date and Time in ISO 8601 Format

github repo

A lightweight Bash script that outputs the current date and time in ISO 8601 format including the timezone offset. This utility provides a consistent and standardized timestamp useful for logging, automation, and scripting workflows.

Features

  • Outputs current date and time in the format: YYYY-MM-DDTHH:MM:SS±HH:MM
  • Uses standard Bash and the Unix date command
  • Minimal dependencies and easy to integrate into other scripts

Tech Stack

  • Shell scripting (Bash)
  • Unix date command

Getting Started

Prerequisites

  • Bash shell
  • date command (available on most Unix-like systems)

Installation

Clone or download this repository. Save the script file current-time.sh to your local machine.

Usage

Make the script executable:

chmod +x current-time.sh

Run the script:

./current-time.sh

Example output:

date = "2024-07-13T14:27:45-06:00"

Project Structure

  • current-time.sh - The main Bash script that outputs the current time.
  • README.md - This readme file.
  • index.md - Additional documentation with usage instructions and metadata.

Future Work / Roadmap

  • Add support for alternative output formats such as UTC or Unix timestamp.
  • Introduce command-line options to customize output format and timezone.
  • Improve portability across different Unix-like systems and shells.
  • Add automated tests to verify output format consistency.

This project is provided as-is without warranty. You may modify and use it as needed.

hjkl / arrows · / search · :family · :tag · :datefrom · :dateto · ~/entries/slug · Ctrl+N/Ctrl+P for suggestions · Ctrl+C/Ctrl+G to cancel
entries 201/201 · entry -/-
:readyentries 201/201 · entry -/-