Time::localtime(3pm) Perl Programmers Reference Guide Time::localtime(3pm)NAME
Time::localtime - by-name interface to Perl's built-in localtime() function
SYNOPSIS
use Time::localtime;
printf "Year is %d
", localtime->year() + 1900;
$now = ctime();
use Time::localtime;
use File::stat;
$date_string = ctime(stat($file)->mtime);
DESCRIPTION
This module's default exports override the core localtime() function, replacing it with a version that returns "Time::tm" objects. This
object has methods that return the similarly named structure field name from the C's tm structure from time.h; namely sec, min, hour, mday,
mon, year, wday, yday, and isdst.
You may also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (Note that
this still overrides your core functions.) Access these fields as variables named with a preceding "tm_" in front their method names.
Thus, "$tm_obj->mday()" corresponds to $tm_mday if you import the fields.
The ctime() function provides a way of getting at the scalar sense of the original CORE::localtime() function.
To access this functionality without the core overrides, pass the "use" an empty import list, and then access function functions with their
full qualified names. On the other hand, the built-ins are still available via the "CORE::" pseudo-package.
NOTE
While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this.
AUTHOR
Tom Christiansen
perl v5.18.2 2013-11-04 Time::localtime(3pm)
Check Out this Related Man Page
Time::localtime(3pm) Perl Programmers Reference Guide Time::localtime(3pm)NAME
Time::localtime - by-name interface to Perl's built-in localtime() function
SYNOPSIS
use Time::localtime;
printf "Year is %d
", localtime->year() + 1900;
$now = ctime();
use Time::localtime;
use File::stat;
$date_string = ctime(stat($file)->mtime);
DESCRIPTION
This module's default exports override the core localtime() function, replacing it with a version that returns "Time::tm" objects. This
object has methods that return the similarly named structure field name from the C's tm structure from time.h; namely sec, min, hour, mday,
mon, year, wday, yday, and isdst.
You may also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (Note that
this still overrides your core functions.) Access these fields as variables named with a preceding "tm_" in front their method names.
Thus, "$tm_obj->mday()" corresponds to $tm_mday if you import the fields.
The ctime() function provides a way of getting at the scalar sense of the original CORE::localtime() function.
To access this functionality without the core overrides, pass the "use" an empty import list, and then access function functions with their
full qualified names. On the other hand, the built-ins are still available via the "CORE::" pseudo-package.
NOTE
While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this.
AUTHOR
Tom Christiansen
perl v5.12.1 2010-04-26 Time::localtime(3pm)
Can anyone tell me why this program won't kick out when the time gets beyond time in the loop?
sub showtime
{
local($format,$military)=@_;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
if ((! $military) && ($hour > 12)) {$hour-=12;}
... (2 Replies)
ok here is a perl date question not asked befor.
i know i am feeling small for not knowing. BUT!!!!
$ENV{TZ}="US/Central";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime();
how can i do the addition to year so i can get the current year w/o going $ntime=$year+1900;... (3 Replies)
hi ,
I would like to ask how to get past 5 minutes system time and date, if i have following to get current time.
# get current time
($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
$year = $year + 1900;
$mon = sprintf ("%02s",$mon+1);
$mday = sprintf ("%02s",$mday);
$hour =... (1 Reply)
Hi,
I work on HPUX application and i had a query regarding the sleep & localtime system call in HPUX.
Here is the code that we have :
const uint32_t WAKE_INTERVAL_SEC(30*60);
while (true) {
// Find out what time it is
time(¤tTime);... (3 Replies)
Hello All,
I am facing a warning "Argument "" isn't numeric in localtime at"
what i m using is below
my $timestamp = Timestamp(time);
go_log("###############$timestamp###############");
can some one please suggest the way to avoid this message :confused: (6 Replies)
var=50
perl -le "print scalar localtime (time() - "$var"*60);"
The above does subtraction of time,but i need the time format to be
date +%Y%m%d%H%M%S.
How can i achive this (6 Replies)
Hi,
I have given like this to get the time of the sub routine.
my $start = localtime();
print "\n start time: $start \n";
Output
start time: Fri Apr 29 01:01:31 2011
I want to know what is the format of the time.
I am not able to follow is is HH:MM:SS or MM:HH:SS os... (2 Replies)
Hi I have a code like this:
sub WriteEbcdicHeader
{
my $Htimestamp=localtime();#i need to pack and unpack this
my $eheaderline = $Htimestamp;
#packing has to be done here
#unpacking has to be done after packing
print $EOUTFILE
return $eheaderline;
}
sub WriteEbcdicTrailer
{
... (5 Replies)
perl -e '@stat=stat("/etc/passwd");$now_string=localtime($stat);print $ARGV.":$now_string\n"' ./file_name
Please if anyone can describe it.
Thanks in advance (1 Reply)
Hi all,
a=$1 ##
b=`echo "86400 * $a"|bc`
`perl -e 'use POSIX qw(strftime);$now_string = strftime "%d/%m/%Y", localtime(time-$b); print $now_string,"\n";' > date_file`
but im always getting current date; can any one suggest me any the improvement
the above works fine if i use some thing... (2 Replies)