By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,773 Members | 1,724 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,773 IT Pros & Developers. It's quick & easy.

doubt in converting to epoch time

P: 51
hi,
i am using Date::Time and using localtime function to convert a given timestamp to epoch seconds. Everything is fine. The problem comes when we give date someting like 2008-11-31 04:45:45 . The error it is giving is date out of range (0..30). It is not converting date with 31 to its equvivalent epoch seconds.
How to convert this into epoch seconds? Pls give me a solution.

Thanks,
Pavan
Nov 7 '08 #1
Share this Question
Share on Google+
6 Replies


KevinADC
Expert 2.5K+
P: 4,059
You've posted recent questions and appear to never return to read the replies:

About debugging
Diffrence between timestamps
Freeing up memory by undefining perl variables

So I am not inclined to waste my time posting replies anymore.

Regards,
Kevin
Nov 7 '08 #2

P: 51
Dear friend,
I have seen all your replies. I have searched for epoch seconds.
Used them in my program, but at atlast i have got an error when i entered date as 31. I have surfed through the net, asked my quoleagues to solve my problem. But, i could not get the result. I am sorry if i did make a mistake.
Pls help me in solvin this problem.

My problem is:
Expand|Select|Wrap|Line Numbers
  1. use Time::Local;
  2.  
  3. my $a = "2008-04-02 10:23:34";
  4. my $b = localtime($a);   
  5.  
It is working fine. only when u give 31 instead of 30 . i am getting out of range error. So, pls help me in this regard.

Regards,
Pavan
Nov 7 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
Well, considering there is only 30 days in the 11 month........
Nov 7 '08 #4

P: 51
hi, i have added code pls see my reply.

Regards,
Pavan
Nov 7 '08 #5

KevinADC
Expert 2.5K+
P: 4,059
hi, i have added code pls see my reply.

Regards,
Pavan
The code you posted:

Expand|Select|Wrap|Line Numbers
  1. use Time::Local;
  2. my $a = "2008-04-02 10:23:34";
  3. my $b = localtime($a);
  4.  
That does nothing. You loaded Time::Local and didn't use any of its functions, and localtime() doesn't take a date as its argument, it takes epoch seconds as its argument. If no argument is supplied it uses time.
Nov 7 '08 #6

KevinADC
Expert 2.5K+
P: 4,059
I have added reply, please see my reply. DOH !!!!!!!!
Nov 7 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.