- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- 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
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
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.