473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
6 2821
KevinADC
4,059 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
4,059 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
4,059 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
4,059 Expert 2GB
I have added reply, please see my reply. DOH !!!!!!!!
Nov 7 '08 #7

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

Similar topics

1
by: Anand CS | last post by:
Hi All I have question regarding time data structures... I have 64 bit unsigned microsecond resolution (unsigned __int64 for windows/and unsigned long long for others) variable. It stores the...
1
by: Liviu BURCUSEL | last post by:
Hello ! It is late night and I cannot think right anymore. Please help me to convert a interval like '2 days 00:22:10.2905' in seconds. Thank you very much in advance, Liviu ...
3
by: NateM | last post by:
How do I convert any given date into a milliseconds value that represents the number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT? Is there an easy way to do this like...
4
by: Dan Lewis | last post by:
I've imported a ms access database into a table in a mysql database. The access database contains a field that holds date/time values in 'general date' format. These all show up at 01/01/1970 in...
6
by: marc | last post by:
hi im trying to convert Date() into a unix timestamp so i can stick the result into a mysql db, please help!
1
by: Astan Chee | last post by:
Hi, I have a string in this format "DD/MM/YYY" for example: tdate = "18/01/1990" and Im trying to convert this to epoch time, can anyone help? Im also trying to convert that epoch time to the...
1
by: Matt | last post by:
Hi all, So a lot of digging on doing this and still not a fabulous solution: import time # this takes the last_modified_date naive datetime, converts it to a # UTC timetuple, converts that...
3
by: Mark | last post by:
I want to simply get the unix style epoch time (number of secs to now from Jan 01, 1970 UTC) for use as a timestamp to track the staleness of some objects. So I don't care about time zones or...
11
by: usenet | last post by:
Is the epoch time the number of seconds elapsed since January 1st 1970 in my timezone or as per UTC? I mean, if A's program makes a call to time() in Melboune and B's program makes a call to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.