Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date format for PERL in Windows

Status
Not open for further replies.

ranjank

IS-IT--Management
May 9, 2003
176
IN
Hi,

I'm facing the problem wrt to Date format while executing the script in windows.It is properly running in Unix.The date format in Unix is
$Date=`date \"%m %d %y \"`;

When i try to execute this in windows it is givng me the error : "System cannot accept the Date entered"

Perl is installed in windows machine.

Any help on this will be highly appreciated.

Regards,
RK.
 
This works on my XP machine:

Code:
$day='30';
$month='06';
$year='2005';
$Date='date'.' '.$day.'-'.$month.'-'.$year;
system("$Date");
 
Thanks for the reply.I need something that works in Unix as well as windows.The same format for both.Is it possible?

Thanks,
RK.
 
The date format required by my HPUX box differs from that of my XP workstation.

HPUX requires:
date -u mmddhhmmccyy

whilst XP is looking for:
date dd mm ccyy

With these 2 system I don't see how you can use one command for both since the commands differ! The best I can think of is to use an if statement - if Windows do command 1, if unix do command 2.

 
ranjank - are you trying to set the date or get the date in a particular format?
 
If you are really trying to change the system date, then you need different code for different platforms as noted above.

But if you are just trying to work with a date different than the system date, you can use Time::Local to convert mo day year values to epoch seconds.

Tony Lawrence
Linux/Unix/Mac OS X Resources
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top