- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: perl localtime to get format
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2007 09:22 AM
03-02-2007 09:22 AM
perl localtime to get format
YYMMDDHHMMSS
- Tags:
- localtime
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2007 09:32 AM
03-02-2007 09:32 AM
Re: perl localtime to get format
Use the POSIX::strftime module. THe directives are the same as the libc ones.
# perl -MPOSIX=strftime -e 'print strftime("%Y%m%d%H%M%S\n",localtime)'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2007 09:33 AM
03-02-2007 09:33 AM
Re: perl localtime to get format
sub do_1_timestamp
{
use integer;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($_[0]);
my $s_tmp = sprintf("%02d%02d%02d%02d%02d%02d",
($year + 1900) % 100,$mon + 1,$mday,$hour,$min,$sec);
return($s_tmp);
} # do_1_timestamp
print "Current Time is ",do_1_timestamp(time()),"\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2007 08:35 AM
03-06-2007 08:35 AM
Re: perl localtime to get format
chomp( my $dispdate = `date +%Y-%m-%dT%X.000` );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2007 08:46 AM
03-06-2007 08:46 AM
Re: perl localtime to get format
The downside of your own solution is that you are invoking the shell to run the 'date' command. This adds the creation of an unnecessary process to do what Perl can do directly.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2007 08:58 AM
03-06-2007 08:58 AM
Re: perl localtime to get format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2007 09:03 AM
03-06-2007 09:03 AM
Re: perl localtime to get format
I know I was going to open up a can of worms with this one.