To get seconds from current time in Bash script, use date command with format that returns only the seconds.
The syntax to get seconds from current time is
In the following script, we take the seconds from current time in variable
seconds, and echo it to the standard console.
seconds=$(date +%S) echo "Seconds : $seconds"
Seconds : 14
In this Bash Tutorial, we have learnt how to get seconds from current date and time in Bash Script using date command.