By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,276 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,276 IT Pros & Developers. It's quick & easy.

how to store my date in variables using locatime

100+
P: 170
hey guys,

Expand|Select|Wrap|Line Numbers
  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);
  3.  
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
May 13 '08 #1
Share this Question
Share on Google+
2 Replies


nithinpes
Expert 100+
P: 410
Expand|Select|Wrap|Line Numbers
  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";
  4.  
The sprintf() function is used to format string/variables and return the formatted string to a variable.
May 13 '08 #2

100+
P: 170
thanks a lot nithinpes..u helped me a lot
May 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.