Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

how to store my date in variables using locatime

Question posted by: poolboi (Familiar Sight) on May 13th, 2008 03:30 AM
hey guys,

Code: ( text )
  1. ($sec, $min, $hrs, $day, $month, $year) = (localtime) [0,1,2,3,4,5];
  2. printf("%04d-%02d-%02d\n", $year+1900, $month+1, $day);


the above right print the date say today:
2008-05-13

how do i store the in a variable say $date
cos i want to use it later in the later part of my script
thanks
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
nithinpes's Avatar
nithinpes
Expert
205 Posts
May 13th, 2008
04:50 AM
#2

Re: how to store my date in variables using locatime
Code: ( text )
  1. ($sec, $min, $hrs, $day, $month, $year) = (localtime) [0,1,2,3,4,5];
  2. $date = sprintf("%04d-%02d-%02d\n", $year+1900, $month+1, $day);
  3. print "$date";


The sprintf() function is used to format string/variables and return the formatted string to a variable.

Reply
poolboi's Avatar
poolboi
Familiar Sight
168 Posts
May 13th, 2008
06:06 AM
#3

Re: how to store my date in variables using locatime
thanks a lot nithinpes..u helped me a lot

Reply
Reply
Not the answer you were looking for? Post your question . . .
170,099 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Perl Forum Contributors