LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-23-2002, 11:18 AM   #1
Syncrm
Member
 
Registered: Aug 2001
Location: Lansing, Michigan
Distribution: slackware8+
Posts: 472

Rep: Reputation: 30
perl and date manipulation


hello...
i'm writing a perl script which will take my http access logs and put them into a mysql database. so far everything is working create, except that rather than have the standard log form of "28/Mar/2002" i would like to just have the unix time stored (being the number of seconds that has elapsed since its creation), and work with the date from there. i know it's possible with PHP (which i'm very familiar with), however i'm trying to do this in perl as i'd like to become more experienced with perl. the PHP function is merely date("Ymd", time()) and can also be done in reverse order.

so does anyone know of a similar method in perl? thank you. :-)
 
Old 05-23-2002, 01:45 PM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
I don't know perl but on the command line you can just run the command:

date +%s

I'm sure you will be able to grab the output of that command in your perl script.
 
Old 05-23-2002, 02:23 PM   #3
Syncrm
Member
 
Registered: Aug 2001
Location: Lansing, Michigan
Distribution: slackware8+
Posts: 472

Original Poster
Rep: Reputation: 30
yes, but is it possible to convert a date that already exists (say "28/Mar/2002") into unix time?

thanx. :-)
 
Old 05-24-2002, 03:53 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
My knowledge of perl doesn't go that far. Maybe this will help you out further:

http://www.perldoc.com/perl5.6/faq/p...epoch-seconds-
 
Old 05-24-2002, 08:17 AM   #5
Syncrm
Member
 
Registered: Aug 2001
Location: Lansing, Michigan
Distribution: slackware8+
Posts: 472

Original Poster
Rep: Reputation: 30
thanx, that was a lot of help. i've got it figured out now!

 
Old 10-28-2002, 02:05 AM   #6
lingling
LQ Newbie
 
Registered: Oct 2002
Posts: 1

Rep: Reputation: 0
how to make access logs using perl scripts
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl/bash - calculate date in future rose_bud4201 Programming 6 05-10-2009 05:59 AM
Perl: get file date kenneho Programming 5 11-01-2005 11:16 AM
date manipulation in shell peal_ss Programming 4 03-29-2004 04:43 AM
date command manipulation issue tjtoed Red Hat 1 02-04-2004 10:10 AM
Typeglob manipulation in Perl coolman0stress Programming 0 10-27-2003 06:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration