Ubuntu: How to View the Current Date and Time via Command Line CodeUnit 14 JUN 2010

If you are working on an Ubuntu server installation that comes in the command line only variation, you might at any point in time want to see just what exactly the server’s time is currently set to.

Needless to say, getting the current date and time information is pretty damn easy – simply call:


Seriously, as simple as that.

Now if you wanted to say change the date or time on the server, it turns out that this is pretty simple to acheive as well:

Simply provide a parameter to the date function!

So we would then have:

sudo date newdatetimestring

Of course, you won’t exactly use “newdatetimestring”, rather it stands for the date time format “nnddhhmmyyy.ss” where nn is a two digit month (01 to 12), dd is a two digit day (01 to 31), hh is two digit hour (00 to 23), yyyy a four digit year and finally .ss which is two digit seconds (00 to 59) [notice the ‘period’ there by the way].


Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.

  • Vivfren

    Id like to know how to do it. Please send me a mail vivfren@yahoo.com

  • Rather than setting your date and time manually, it is often more accurate to run:

    sudo ntpdate-debian

    and that will synchronise your clock to an accurate NTP server.

  • Pingback: ubuntu : change the date in terminal « from me for you world()

  • It may also be useful to change the time zone first while you’re at it with:

    sudo dpkg-reconfigure tzdata

    *Then* adjust the time following the “mmddhhccyyyy.ss” format. For example, use

    sudo date 060511522014.45

    To set the current time to 2014, June the 5th at 11:52:45