Nishi Prafull wrote:
> HI:
> 
> I want to write a perl script that would compute the date in the
> format yymmdd(050303) and subsitute it for a variable in the perl
> script. This variable is thereafter subsituted in a command that will
> be run inside the script.
> 
> myTest.pl
> 
> var aDate;
        You can do it a number of ways, here is a start on one way:

my @MyDateTime = ();
@MyTime = localtime( time );
$MyDateTime[4]++;               #months start at zero, so must add 1
#
# Now the array has the date and time info in the following elements:
#    0    1    2     3     4    5     6     7     8
#   (sec, min, hour, mday, mon, year, wday, yday, isdst)
# mday is Day of Month
# year is number of eyars from 1900
# wday is day of week: 0:Sun and 6: Sat
# yday is number of days from 1 Jan 
# isdst if true then Daylight savings time is on
        So to get your date in the format:
my $aDate = sprintf "%02d%02d%02d",
                                        $MyDateTime[5] % 100,           % does 
a modulo against the year, so 105 comes out as 5, 106 as 6
                                        $MyDateTime[4],
                                        $MyDateTime[4];

$aDate should now have 050303

Wags ;)

> get todays date and convert it to yymmdd and assign it to aDate
> subsitute in a command such as
> $cmd = "integrate -t push -l $aDate"
> system($cmd);
> 
> I will be running this script on unix. But I would like to be able to
> get the date value platform independant.
> 
> Thanks.



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to