如何在Perl中更改日期格式? [英] How can I change the date formats in Perl?

查看:75
本文介绍了如何在Perl中更改日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想将日期从20111230格式转换为30-dec-2011.

I just want to convert the dates from 20111230 format to 30-dec-2011.

推荐答案

与TMTOWTDI保持一致,您可以使用

In keeping with TMTOWTDI, you can use Time::Piece

#!/usr/bin/env perl
use strict;
use warnings;
use Time::Piece;
my $t = Time::Piece->strptime("20111230", "%Y%m%d");
print $t->strftime("%d-%b-%Y\n");

这篇关于如何在Perl中更改日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆