Technology Software

GNU/Linux Command-Line Tools Summary

   GNU/Linux Command-Line Tools Summary
   Prev    Chapter 8. Finding information about the system    Next

8.1. Date/Time/Calendars


There is one command to change both the date and time on a UNIX like system, date , there is also a simple calendar utility, cal . If you are looking to change the timestamps on files please see Chapter 8
  • date
  •    
    Tells you the date (and the time) and is also used to set the date/time.

    To set the date, type date MM:DD:YYYY (American style date) where MM is month, DD is the number of days within the month and YYYY is the year.

    For example to set the date to the 1st January 2000 you would type:

       
    date 01:01:2000

    To set the time (where the -s option is to set a new time), type:

       
    date -s hh:mm:ss

    Another useful option you can use is --date="string" (or -d"string" ) option to display a date from x days ago or in x days (or x weeks, months, years et cetera). See the examples below.

    Examples:

       
    date --date="3 months 1 day ago"

    Will print the date 3 months and 1 day ago from the current date. Note that --date="x month x day ago" and -d "x month x day ago" are equivalent.

       
    date -d "3 days"

    The above command will print the date 3 days in the future from now.



  • cal
  •    
    Typing cal will give you the calendar of the present month on your screen, in the nice standard calendar format. There are various options to customise the calendar, refer to the info/man page.

    Example:

       
    cal -y year

    Will display a calendar for a specific year, simply use cal -y to print the calendar for the current year.

       
    cal 2 2004

    This will display the calendar for February 2004



   Prev    Home    Next
   Finding information about the system    Up    Finding information about partitions



* License

* GNU/Linux Command-Line Tools Summary Index

Related posts "Technology : Software"

How to Put My FB to Sleep

Software

Some Useful Tips to Avoid Hack Attacks

Software

CREN

Software

How to Transfer DVD to 3GP

Software

How to Troubleshoot if My Computer Only Types in Wingdings

Software

What Cloud Computing Really Means

Software

How to Make More Points Visible on Scatter Plots in Excel for Mac

Software

How to Make a Spreadsheet Without Excel

Software

Enhancing VOB Videos to MPEG Format

Software

Leave a Comment