01-26-2006
$ more test1.pl
#!/sbcimp/run/pd/perl/5.6.1/bin/perl
my ($date1,$date2,$date3,$date4,$date5,$date6,$date7,$date8,$date9,$date10,$date11,$date12);
my ($day,$mnth,$year) = (localtime (time)) [ 3,4,5 ];
$year+=1900;
$mnth+=1;
for( my $i=1; $i <= 12; $i++ ) {
my $str=sprintf("\$date$i=\"%02d/01/$year\"",$mnth);
eval $str;
$mnth++;
if ( $mnth > 12 ) { $mnth=1; $year++; }
}
for( my $i=1; $i <= 12; $i++ ) {
my $str=sprintf("print \"\$date$i\\n\"");
eval $str;
}
$ test1.pl
01/01/2006
02/01/2006
03/01/2006
04/01/2006
05/01/2006
06/01/2006
07/01/2006
08/01/2006
09/01/2006
10/01/2006
11/01/2006
12/01/2006
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello friends,
I am looking for a script or method that can display all the dates between any 2 given dates.
Input:
Date 1
290109
Date 2
010209
Output:
300109
310109
Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies
2. Shell Programming and Scripting
Hi,
Is there any way I can get the difference between two dates in terms of days?
I have used this method so far, but I cant format it in terms of days.
@a=&DateCalc($date1,$date2,0);
The o/p that I am getting is sort of like this:
+0:0:0:4:0:0:0
I just want to get 4 days as an o/p.... (1 Reply)
Discussion started by: King Nothing
1 Replies
3. Shell Programming and Scripting
Hi,
I need help to toggle through dates on a weekly basis to be fed into a script as inputs. The format should be: yyyy/mm/dd (start) yyyy/mm/dd (end), where end date is 7 days increments.
The date (start) would be input as an ARGV and would continue until current date.
I can check... (2 Replies)
Discussion started by: subhap
2 Replies
4. Shell Programming and Scripting
Hi guys,
First of all, I would like to say this is my first post in the unix.com forums. I am a beginner in PERL and have only started writing my first scripts.
With that out of the way, I have a question regarding the calculation of time dates in PERL.
I have two scalar variables with the... (1 Reply)
Discussion started by: DiRNiS
1 Replies
5. Shell Programming and Scripting
I have a directory of backup files.
named like this:
ldap.data.04-06-2012.tar
ldap.data.03-06-2012.tar
ldap.data.02-06-2012.tar
ldap.data.01-06-2012.tar
ldap.data.31-05-2012.tar
ldap.data.30-05-2012.tar
ldap.data.29-05-2012.tar
ldap.data.28-05-2012.tar
ldap.data.27-05-2012.tar... (6 Replies)
Discussion started by: robsonde
6 Replies
6. Shell Programming and Scripting
Hi,
how to calculate the time difference between PST date and PDT date in perl scripting.
date1: Mon Dec 31 16:00:01 PST 2015
date2: Tue Mar 19 06:09:30 PDT 2013
and also difference between PST-PST and PDT-PDT
need difference in months or days (months prefereble). (3 Replies)
Discussion started by: praveen265
3 Replies
7. Shell Programming and Scripting
Hi
i have a file containg dates likebelow
4/30/2013
3/31/2013
4/30/2013
4/16/2013
4/30/2013
4/30/2013
5/30/2013
5/30/2013
4/30/2013
5/30/2013
5/30/2013
3/31/2013
now i want to compare the above dates with current date and i want to display the difference . (10 Replies)
Discussion started by: siva kumar
10 Replies
8. Programming
Hi All
I have a text file that has a list of dates in it ( see below example) is there i can just pull out the lines that are from this week ( week starting on monday) and then work out the how many occurances there are on each name in collum 2
2013-05-13 08:20:02 bacha ... (8 Replies)
Discussion started by: ab52
8 Replies
9. Shell Programming and Scripting
Hello All,
I have two strings with date and time as follows..
$starttime= "06/11/2013 ";
$starttime= "05:15";
$enddate="06/12/2013";
$endtime="04:45";
dates are in mm/dd/yyyy format and time in military format.
and I am looking the duration of time(in minutes) in between dates.
... (3 Replies)
Discussion started by: scriptscript
3 Replies
10. Shell Programming and Scripting
hello folks,
I have a requirement in which I have to calculate the difference of
localdate(today's date) and the given(earlier) date and to check whether the
difference is exactly a year or more than that(can be 1 year or 2 years or 3 years.. ) .
Could anyone please let me know the logic... (2 Replies)
Discussion started by: scriptscript
2 Replies
LEARN ABOUT PHP
localtime
LOCALTIME(3) 1 LOCALTIME(3)
localtime - Get the local time
SYNOPSIS
array localtime ([int $timestamp = time()], [bool $is_associative = false])
DESCRIPTION
The localtime(3) function returns an array identical to that of the structure returned by the C function call.
PARAMETERS
o $timestamp
- The optional $timestamp parameter is an integer Unix timestamp that defaults to the current local time if a $timestamp is not
given. In other words, it defaults to the value of time(3).
o $is_associative
- If set to FALSE or not supplied then the array is returned as a regular, numerically indexed array. If the argument is set to
TRUE then localtime(3) returns an associative array containing all the different elements of the structure returned by the C func-
tion call to localtime. The names of the different keys of the associative array are as follows:
o "tm_sec" - seconds,
0 to 59
o "tm_min" - minutes,
0 to 59
o "tm_hour" - hours,
0 to 23
o "tm_mday" - day of the month,
1 to 31
o "tm_mon" - month of the year,
0 (Jan) to 11 (Dec)
o "tm_year" - years since 1900
o "tm_wday" - day of the week,
0 (Sun) to 6 (Sat)
o "tm_yday" - day of the year,
0 to 365
o "tm_isdst" - is daylight savings time in effect? Positive if yes,
0 if not, negative if unknown.
ERRORS
/EXCEPTIONS
Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT or E_WARNING message if using
the system settings or the $TZ environment variable. See also date_default_timezone_set(3)
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.1.0 | |
| | |
| | Now issues the E_STRICT and E_NOTICE time zone |
| | errors. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
localtime(3) example
<?php
$localtime = localtime();
$localtime_assoc = localtime(time(), true);
print_r($localtime);
print_r($localtime_assoc);
?>
The above example will output something similar to:
Array
(
[0] => 24
[1] => 3
[2] => 19
[3] => 3
[4] => 3
[5] => 105
[6] => 0
[7] => 92
[8] => 1
)
Array
(
[tm_sec] => 24
[tm_min] => 3
[tm_hour] => 19
[tm_mday] => 3
[tm_mon] => 3
[tm_year] => 105
[tm_wday] => 0
[tm_yday] => 92
[tm_isdst] => 1
)
SEE ALSO
getdate(3).
PHP Documentation Group LOCALTIME(3)