Advertisement

01.26.2005 at 06:03PM PST, ID: 21290331
[x]
Attachment Details

Problem with mktime not producing any output

Asked by Donboy in Perl Programming Language

Tags: perl

I have a script I put together based on another script that I have seen posted here on this site.  Basically I want to take a hyphenated date and pass it to my script on STDIN and produce a perl/unix timestamp on STDOUT.  But for some reason, the the $timestamp variable isn't showing any output.  Can someone help?

#!/usr/bin/perl

use POSIX;

$hyphendate = shift;

($StoredMonth,$StoredDay,$StoredYear)=split(/-/,$hyphendate);

$sec = 0;
$min = 0;
$hour = 0;
$mday = $StoredDay;
$mon = $StoredMonth - 1;
$year = $StoredYear - 1900;
$wday = 0;
$timestamp = mktime($sec,$min,$hour,$mday,$mon,$year);
print "-> $timestamp <- $hyphendate\n"; Start Free Trial
[+][-]01.26.2005 at 06:15PM PST, ID: 13148898

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.26.2005 at 06:42PM PST, ID: 13149031

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: perl
Sign Up Now!
Solution Provided By: Tintin
Participating Experts: 2
Solution Grade: A
 
 
[+][-]01.26.2005 at 06:58PM PST, ID: 13149102

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32