Categories
Linux [11]
Archives
February 2008 |
how to print the date from one date to another dateguocongbin | 12/28 2007, 06:46
The question is got from a forum. Actually, the question is very simple if you understand the usage of command `date`. date is a very insteresting command, which can understand what you said in netural language. eg. $date --date='2 days ago' Wow, it know what do you want! For more powerful feature, you could man it or info it. As far as the question in titile, if we can convert the date string into seconds from 1970-1-1, it would be solved easily. For example, we need to print all date from 2007-7-1 to 2007-8-1. First we need to know how many seconds of two dates from 1970-1-1 00:00:00. $date -d 2007-7-1 +%s $date -d 2007-8-1 +%s Okay, then it should be know that command date not only can convert a date string to the seconds from era, but also can convert a seconds to a date string. e.g. $date -d "2007-1-1 12345sec" Oops, so powerful. Okay, i think you may know the answer of the question. #!/bin/bashor #!/bin/bash
Comments29 Responses to “how to print the date from one date to another date”2 3 4 5 6 7 8 9 10 11 12 13 14 16 17 19 20 21 22 23 24 25 26 27 28 29 Add comment |
SEXlink1