How to set the date and time on Linux

A quick post for how to set the date and time on Oracle Linux via the date command. This post is more for my own documentation but hey, it might help others as well. To set a date or time you have to pass on the information via a formatted string to the date command. I find calling date twice, once for the date and once for the time, the easiest. The +%D format option allows you to pass on the date as YYYY-MM-DD, e.g. 2019-08-01 for the 1st of August 2019. To set the time, I use the +%T format option to pass on the time as HH24:MI:SS, e.g. 22:31:04.

date +%D -s 2019-08-01
date +%T -s 22:31:04

Format:

date +%D -s YYYY-MM-DD
date +%T -s HH24:MI:SS

Author: Gerald

Developer, Oracle expert, performance enthusiast and genuine technology geek.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.