The date command can get the current time. man shows that many parameters of date can be used, which is easy to format. for example: date + "% F" output format: 2011-12-31date + "% F % H: % M: % S" output format: 2011-12-3116: 29: 50. the current time of the system is printed, if you want to obtain a time relative to the current time, you can use the-d parameter. Example: date-d "tomorrow"
The date command can get the current time. man shows that many parameters of date can be used, which is easy to format. for example:
Date + "% F" output format: 2011-12-31date + "% F % H: % M: % S" output format: 2011-12-31 16:29:50
This is to print the current time of the system. if you want to obtain a time relative to the current time, you can use the-d parameter. For example:
Date-d "tomorrow" + "% F % H: % M: % S" output date-d "yesterday" + "% F % H: % M: % S "output the time at this time yesterday
If I want to get the time of 13 days ago, the-d parameter has more flexible usage, for example:
Date-d "-1 day ago" + "% F % H: % M: % S "output date-d" 1 day ago "+" % F % H: % M: % S "output date-d" 1 week ago "+" % F % H: % M: % S "output time seven days ago, equivalent to date-d "7 day ago" + "% F % H: % M: % S"
We can see that ago is powerful. The first number can be a negative number, and the negative number indicates the future time. the positive number indicates the past time, the second parameter is minute, hour, day, month, and week.