Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux date format hh-mm-ss

Tags:

date

linux

bash

I got a problem if the time is before 10, because then the output is like 8-33-21 instead of 08-33-21. My date syntax is date +"%k-%M-%S. Does anyone know how to solve this problem?

like image 543
Sharpy Avatar asked May 04 '26 01:05

Sharpy


1 Answers

The %kformat is space padded

From the man page

%H hour (00..23)

%I hour (01..12)

As fedorqui pointed out, %T is the same as %H:%M:%S

like image 185
Zermingore Avatar answered May 06 '26 13:05

Zermingore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!