LinuxQuestions.org
Review your favorite Linux distribution.
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 04-25-2004, 03:51 AM   #1
michedlp
LQ Newbie
 
Registered: Sep 2003
Posts: 19

Rep: Reputation: 0
Epoch time the other way!


Hey All,
I'm writing a script that will perform various functions depending on what time it is, compared to a time stored in a mysql database.

Through various searching, i've found the easiest way is to use Epoch time. I've gotten the conversion from Epoch to regular-human readable fine, but the other way i can't get working.

In the DB i have the time saved like so: April 25 2 15 PM 2004

Here's the relevant code from the script:



my $sth = $db->prepare("SELECT subtype, effecttype, services, endmonth, endday, endhour, endminute, endampm, endyear FROM transactions");
$sth->execute();

while ( my @info = $sth->fetchrow_array() ) {

my $epoch = parsedate("$info[6] $info[5] $info[4] $info[3] $info[8]");
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime($epoch);


I've tried playing with some parts, but all that happens is i get a raft of uninitialised variables and the script crapping out on me.

Any help would be great!

Thanks
Miche
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Doub about `net time set` and daylight saving time Thakowbbery Linux - Software 0 10-17-2005 05:23 AM
ps2 mouse freezing on FC1/FC2 from time to time farpoint Linux - Hardware 5 08-14-2005 02:20 PM
no signal when starting xorg for the 1st time (but the second time works fine) bungalowbill Linux - Software 0 06-04-2004 09:56 AM
Setting System Time: kernel in wrong time zone warrenweiss Linux - General 7 05-15-2004 03:25 PM
The End of the UNIX Epoch oulevon Programming 10 11-22-2003 02:42 AM


All times are GMT -5. The time now is 07:21 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration