Time on timestamp

Asked

Viewed 392 times

1

Talk it up, boys, it’s all right?

Is it possible I know how much two hours in conversion timestamp?

On this line I convert the current time to timestamp.

$hours_2 = str2time(localtime());

But I need to know how to get two hours out of the result, getting $hours_2 - two hours... I’m not getting anywhere.

1 answer

1

The function of Perl localtime accepts a parameter time which is a Unix Epoch in the seconds drive. In Perl

localtime(time())

is the same thing as

localtime()

Knowing this, to get the result minus two hours, simply remove 2 * 60 * 60 = 7200 seconds of the parameter

my $hours_2 = localtime(time() - 7200);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.