Wednesday, 21 October 2015

date command in Linux

#!/usr/bin/bash
echo "DD-MM-YY format";
date +"%d-%m-%y";
echo "DD-MM-YYYY format";
date +"%d-%m-%Y";
echo "DD/MM/YYYY format";
date +"%d/%m/%Y";
echo 'DD/MM/YYYY--%H-%M-%S format';
date +"%d/%m/%Y--%H-%M-%S";
echo 'DD/MM/YYYY--Hr:Min:Sec format';
date +"%d/%m/%Y--%HHr:%MMin:%SSec";
#-----most general format-----
echo 'DD/MM/YYYY--HH:MM:SS format';
date +"%d/%m/%Y--%T";
echo 'DD/MM/YYYY--HH:MM:SS with AM/PM format';
date +"%d/%m/%Y--%r";

No comments:

Post a Comment