467,104 Members | 963 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

doubt in converting to epoch time

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
  • viewed: 2604
Share:
6 Replies
KevinADC
Expert 2GB
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
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 2GB
Well, considering there is only 30 days in the 11 month........
Nov 7 '08 #4
hi, i have added code pls see my reply.

Regards,
Pavan
Nov 7 '08 #5
KevinADC
Expert 2GB
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 2GB
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.

Similar topics

1 post views Thread by Anand CS | last post: by
1 post views Thread by Liviu BURCUSEL | last post: by
3 posts views Thread by NateM | last post: by
6 posts views Thread by marc@gaspdesign.co.uk | last post: by
1 post views Thread by Astan Chee | last post: by
11 posts views Thread by usenet@sta.samsung.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.