Date on Linux Shell / Bash command line | Drupal 8

Date on Linux Shell / Bash command line

Submitted by editor on Mon, 06/26/2017 - 15:53
Question

Few tips for linux terminal date. manipulate date on linux CLI.

Print / Check Date from command line

date

Set date from the command line

date +%Y%m%d -s "20170430"

Set time from the command line

date +%T -s "12:00:00"

Set time and date from the command line

date -s "30 APR 2017 12:00:00"

 

Print / Get a formatted dater

DATE=$(date +%d-%m-%Y" "%H:%M:%S);
echo  $(date +%d-%m-%Y" "%H:%M:%S);

Write a file using current timestamp as file name.

echo "test"> "File-$(date +%Y%m%d%H%M%S).txt";

Tags

Add new comment