Loving Coding & Visual Design

Compare Date with PERL

(This is one of my English Diary, just for exercise.)
I haven't touch PERL for a long time, feel so tired to debug script error on page with "Internal Server Error", that's the reason I don't like it. But the reason I still use it is because CPAN, it's a huge library for PERL Archive. You can easily find any function you can imagine. Here's a example to Compare Date.
[code lang="per"]
#!/usr/bin/perl
print "Content-type: text/htmlnn";

# you need three packages: Date::Parse, Time::Local, Time::Zone;
# http://search.cpan.org/perldoc?Date::Parse
# http://search.cpan.org/perldoc?Time::Local
# http://search.cpan.org/perldoc?Time::Zone
use Date::Parse;
my $secs = str2time("2008-02-14");
my $now=time();
# check we got something useful back
unless (defined $secs){
die "Can't parse '$time' as a time or daten";
}
print "End as:n", "'$secs' (".gmtime($secs).")
n";
print "Now as:n", "'$now' (".gmtime($now).")
n";
if($now >= $secs){
print "It's time to go now.";
}else{
print "Don't worry, still have time.";
}

[/code]



下一页


最 近 文 章

  1. Google推出web界面的星空版地图 - Mon, 17 Mar 2008 02:22:54 +0000
  2. 转让闲置刀片式宝德服务器一台 - Thu, 13 Mar 2008 12:28:26 +0000
  3. 一些小问题的解决办法 - Tue, 13 May 2008 04:43:05 +0000
  4. 关于图片上传目录777权限的解决办法 - Mon, 10 Mar 2008 08:37:09 +0000
  5. Adsense推荐中等矩形 (300 x 250)来展示广告 - Wed, 05 Mar 2008 12:37:18 +0000
  6. google的工程哲学 - Tue, 04 Mar 2008 12:55:43 +0000
  7. 利用“301”HTTP头给网站更换域名 - Fri, 29 Feb 2008 02:07:05 +0000
  8. 话筒的烦恼 - Wed, 27 Feb 2008 16:33:39 +0000
  9. Windows批处理(BAT)技巧 - Wed, 27 Feb 2008 05:01:28 +0000
  10. GoogleMap推出静态地图引用服务 - Fri, 22 Feb 2008 05:39:50 +0000