Created
June 14, 2020 08:07
-
-
Save ajermakovics/c55f0b7dc69f11aa218e4393725381c4 to your computer and use it in GitHub Desktop.
Date to timestamp (macOS)
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
#!/bin/bash | |
# Convert given date to timestamp | |
# Date format: YYYY-MM-DD (2020-02-28) | |
# If no argument given use current date | |
CURDATE=`date +%F` | |
DATE=${1:-$CURDATE} | |
echo "Arg/Cur: $DATE" | |
IFS=- | |
set $DATE | |
YEAR=$1 | |
MONTH=$2 | |
DAY=$3 | |
echo "Parsed: $YEAR/$MONTH/$DAY" | |
echo Date $DATE timestamp: | |
TS=`date -j $MONTH$DAY$YEAR +"%s"` | |
echo $TS | |
echo ${TS}000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment