Skip to content

Date: Advanced Usage of the Date Command

Introduction

The date command can be very useful for advanced date calculations.

Usage

  • Calculates the date 2 weeks ago from Saturday in the specified format:
date -d '2 weeks ago Saturday' +%Y-%m-%d
  • Unix alias for date command that lets you create timestamps in ISO 8601 format:
alias timestamp='date "+%Y%m%dT%H%M%S"'