====== Datetime - Fu ====== ===== Con el comando date podemos conocer la fecha y hora actual: ===== {{pasted_image_20230128174415.png|}} ===== Si quisiera mostrar el día, utilizo el comando date +%A: ===== {{pasted_image_20230128175139.png|}} ===== Y si también quiero el día del mes, pongo %d: ===== {{pasted_image_20230128175204.png|}} ===== Y si quiero saber el mes en que estamos, puedo poner %B: ===== {{pasted_image_20230128175242.png|}} ===== Print UNIX time (seconds since Jan 1, 1970, 00:00:00 UTC) ===== perl -le 'print time' ===== Print GMT (Greenwich Mean Time) and local computer time ===== perl -le 'print scalar gmtime' perl -le 'print scalar localtime' ===== Print local computer time in H:M:S format ===== perl -le 'print join ":", (localtime)[2,1,0]' ===== Print yesterday’s date ===== perl -MPOSIX -le '@now = localtime; $now[3] -= 1; print scalar localtime mktime @now' ===== Print date 14 months, 9 days and 7 seconds ago ===== perl -MPOSIX -le '@now = localtime; $now[0] -= 7; $now[4] -= 14; $now[7] -= 9; print scalar localtime mktime @now' ===== Prepend timestamps to stdout (GMT, localtime) ===== tail -f logfile | perl -ne 'print scalar gmtime," ",$_' tail -f logfile | perl -ne 'print scalar localtime," ",$_'