Hi Guys,
Could you tell me how you can get the time stamp for 60th minutes?
Currently, we name our file using time stamp upto minutes and then add seconds at the end starting from 01.
And when the seconds reaches 60 we simply add 1 to the time stamp and reset the seconds to 00.
But the problem occurs when the minute hits 60.
For example, file name starts from
20090330225900.csv then goes to
20090330225959.csv.
Then instead of going to
20090330230000.csv it goes to
20090330226000.csv.
Following is the code,
$seconds_count = 1;
$date_r = `date +%Y%m%d%H%M`;
$date_r = substr($date_r,0,-1);
foreach $blahblah{
if (length($seconds_count) == 1){
$seconds_count = "0" . $seconds_count;
}
# Build up the filename
$filename = " .
$date_r .
$seconds_count .
".csv";
$seconds_count++;
if ($seconds_count > 59){
$date_r = $date_r + 1;
$seconds_count = 0;
}
Do you recon the following would work?
if ($seconds_count > 59){
$date_r = `date +%Y%m%d%H%M`+ 1;
$seconds_count = 0;
}