LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change this? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-this-682765/)

prakash.akumalla 11-11-2008 11:00 PM

How to change this?
 
Hai,

I have written a script in perl which retrieve log data from database If we give the time from which it is received

perl getlog.pl -F '2008:11:01 00:00:01' give the logs that are received after 2008:11:01 00:00:01

Now what I want to do is, The value of F (From time in the above command) should be taken by default such that its value should be 5 hours before the current time.

How can I do this.

Please help me in doing this.

Thanks,
Prakash.

chrism01 11-11-2008 11:31 PM

Well, this gives you the time now: http://perldoc.perl.org/functions/time.html
You can then do

$then = $now - (5 * 3600);

If you need to convert the result to a different date-time format, see the references on that page ie 'localtime' and the DateTime module.


All times are GMT -5. The time now is 11:46 AM.