Linux for new users part 7 – timezone

Continuing my series for those new to running Moodle on a linux server and using a Terminal.

Open a terminal using Ctrl+Alt+T (or whatever method you prefer now). We will conclude exploring the date command this month. But remember, we are really practising using the command line, not trying to memorise all the date options, lol. We are reinforcing the fact that commands have options, and these are case-sensitive.

  • %z prints the time difference between your timezone and UTC.
  • %:z prints the time difference between your timezone and UTC, with a : between the hours and minutes.
  • %::z prints the time difference between your timezone and UTC, with a : between the hours, minutes and seconds.
  • %Z prints the alphabetic timezone name.

Notice the use of upper and lower case characters, and the : and ::

There are some useful formatting options in the date command too:

  • %p prints the AM or PM indicator in uppercase.
  • %P prints the am or pm indicator in lowercase.
  • Note the quirk with these two options. A lowercase p gives uppercase output, and an uppercase P gives lowercase output !
  • %t prints a tab.
  • %n prints a new line.

One try useful thing you can do now in the Terminal, with your date command, is to display the last modification time of a file. Use the -r (reference) option. Note that this uses a – (hyphen) instead of a % sign, and it doesn’t require a + sign. Try this command in your home folder.

Note that I’ve replaced <filename> with the actual name of a file, in this case a graphic file called website_transparent.png.

date -r <filename>

And the results show me that the website_transparent.png file was last modified (saved/updated) on Tuesday 21st November 2017 at 2.51 in the afternoon.

Well, that’s it for date and time. We haven’t covered everything, but the point wasn’t to master the date command, but to use it to get familiar with the Terminal, and to understand how linux commands take values, and how those are always case sensitive.

Starting with the next post we will look at some tricks and useful skills when using the Terminal itself.

Latest posts by Stuart Mealor (see all)

Stuart Mealor

Stuart is interested in all things e-learning, with specific interests in Moodle, e-learning strategy, and business development. His experience in education over 30 years, MBA in International Business, and knowledge of e-learning systems implementation, together with graphic design background, give him a unique skill set for e-learning projects.

Add a reply or comment...

%d bloggers like this: