Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include time stamp on a CGI output calendar??? 1

Status
Not open for further replies.

erdog

Technical User
Dec 31, 2006
8
US
I have a calendar script, "calendar.pl" that parses a template and a data file "calendar_events.txt", which contains the events to output a calendar. My question is, how can I include the last modified for the "calendar_events.txt" into the output?

One idea was to create code that would parse ssi flastmod but I am not sure about how to do that.

Any help would be greatly appreciated.
 
Code:
# Get last modified time of the file
my $mtime = (stat("calendar_events.txt"))[9];

print localtime($mtime);

-------------
Cuvou.com | The NEW Kirsle.net
 
Thanks. That worked like a charm. Now how do I control the formatting of the date/time and also subtract out 3 hours to account for the fact that the server time is +3 hours from me?

Thanks I really appreciate your help Kirle.
 
The format I am looking for is "00:00 PM Dec 31, 2006" if possible with a 12 hour format. If not,

then "00:00 Dec 31, 2006 will suffice
 
Darn this didn't work for me. I looked my host's installed perl modules and didn't find Time::Format. Any other options?

Sorry if I am asking stupid questions, I have not been working with perl in a long time since I stopped learning it because my job description changed.
 
You can just copy Format.pm into a folder called Time in the same directory as your Perl script.

-------------
Cuvou.com | The NEW Kirsle.net
 
That worked...Thanks.

So if I wanted to adjust time for -3 hours, would the code look like:

Code:
my $mtime = (stat("calendar_events.txt"))[9];
use Time::Format qw(time_format);
print time_format ('HH:mm{in} AM Mon dd, yyyy', $mtime-3*24*60*60);
 
Nevermind, I got it to work. Saw that I calculated for days and not hours...ooops. Thank you so much Kirsle.
 
nothing wrong with Time::Format, continue to use it if you prefer to. Another way that is widely supported is using POSIX:


Code:
use POSIX 'strftime';
my $mtime = (stat("calendar_events.txt"))[9];
print strftime("%I:%M %p %b %d, %Y",localtime($mtime-10800));

-10800 is a three hour negative offset of the value of $mtime (60*60*3).





- Kevin, perl coder unexceptional!
 
Thanks Kevin for the additional help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top