You see, if your script is french you need an array of daynames and monthnames in french.
If you want yyyy-mm-dd to insert into a database, you need to format If you don't want to have the year after the time, you need to edit. If you want the th, nd, st after the date also If you want the 05 instead of 5 you need a printf or sprintf That's why there are many out there! Your script has 2 lines, mine have a 4 line sub in a separate used file and the call takes one line, and I can format is the way I want, and since I'm using it really often for DB inserts, it's better suited for my needs:-) So everyone can choose a different method according to the needs Etienne Matt Richter wrote: > > Hmmm.. > I've seen these examples in books and previously on this list. I'm > surprised by the amount code it takes to display the current date. > On my script which outputs to html (i.e. a cgi script), I have the > following > > .... > $ltime = localtime(); > print "<p><b><font face=Verdana size=4>$ltime</b><br>\n"; > .... > > Which prints: Wed Dec 5 17:36:05 2001 > > With all of the coding required shown by the other examples, it makes me > wonder how my code is working. Also, I don't include: use > Time::localtime; > Is it a function of my server or the CGI module that makes my code work? > Will this fail if I move the script to a different server? > > Just Wondering. > > Matt Richter > > -----Original Message----- > From: Etienne Marcotte [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 05, 2001 10:36 AM > To: Shinagare, Sandeep > Cc: '[EMAIL PROTECTED]' > Subject: Re: today's date.... > > sub get_date { > my @months = qw(January Febuary March April May June July August > September October November December); > my ($day, $mon, $yr) = (localtime)[3,4,5]; > return (sprintf("%02d", $day), $months[$mon], $yr + 1900); > } > > my ($day, $month, $year) = get_date(); > > You need to "code" the conversion I think, and also note that the month > number is always 1 less than the actual monthy number because january is > 0. There is maybe a way to get the month name, but I'm not aware if it > > And the year is 1900 years less than the actual year. > > Putting get_date in a sub make it available everywhere.. > > HTH > > Etienne > > "Shinagare, Sandeep" wrote: > > > > Hi Folks! > > Trying to get todays date and month... was able to find this... > > > > #snip-start > > use Time::localtime; > > $tm = localtime; > > ($DAY, $MONTH, $YEAR) = ($tm->mday, $tm->mon, $tm->year); > > #snip-end > > > > this gives me the Day and Month in numbers.. anyway in which i > > can get "Mon","Tue","Wed" and "Jan","Feb","Mar" etc.. other than > > coding the conversion? > > > > Thanks, > > Sandeep > > > > ********************************************************************** > > COLT Telecommunications > > Registered in England No. 2452736 > > Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ > > Tel. 020 7390 3900 > > > > This message is subject to and does not create or vary any contractual > > relationship between COLT Telecommunications, its subsidiaries or > > affiliates ("COLT") and you. Internet communications are not secure > > and therefore COLT does not accept legal responsibility for the > > contents of this message. Any view or opinions expressed are those of > > the author. The message is intended for the addressee only and its > > contents and any attached files are strictly confidential. If you have > > received it in error, please telephone the number above. Thank you. > > > > > ************************************************************************ > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > Etienne Marcotte > Specifications Management - Quality Control > Imperial Tobacco Ltd. - Montreal (Qc) Canada > 514.932.6161 x.4001 > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Etienne Marcotte Specifications Management - Quality Control Imperial Tobacco Ltd. - Montreal (Qc) Canada 514.932.6161 x.4001 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]