Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Reversing Time

December 13, 1999

Only Superman can reverse time, unless you know of some other way to fly around the earth and make it rotate backwards around its axis. I thought not. Perl can't reverse time either, but it can understand time that is written in the reverse -- that is, the conversion of hours, minutes, seconds, and so forth into epoch time, rather than the other way around.

The standard Perl distribution also includes the module Time::Local. Using this module, you can calculate the epoch time by supplying the seconds, minutes, hours, day of month, month, and year for a given date.

use Time::Local;
$someday=timelocal(0,30,10,15,2,99);
print scalar localtime($someday);

Yields:

Mon Mar 15 10:30:00 1999

This is nice, but we haven't really solved our initial problem: writing the time in epoch seconds isn't comfortable, but neither is writing the time as broken down into seconds, hours, minutes, day of month, and so on. To tell you what we want -- what we really, really want -- is a way to move between human friendly dates such as "April 25, 1985" and epoch seconds. On its lonesome, Perl is not capable of this acrobatic feat out-of-the-box, so we must turn to a Perl module.

Chopped Time
The Perl You Need to Know
Date::Manip Gymnastics


Up to => Home / Authoring / Languages / Perl / PerlfortheWeb




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers