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

How to Convert a date and time to epoch?

P: n/a
I have a bunch of dates in a couple different formats. I would like to
convert them to epoch. The dates are like this

Mon, 12 Jun 2006 09:18:22 GMT
12 Jun 2006 10:37:28 GMT

I can do this in perl easily with the Date::Manip module but don't know
how to do it in c#. Is there a way to do this or do I need to right
something to parse each date?

Jun 19 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

For that u can use DateTime class.

DateTime dt = new DateTime.Now;

By this u will get current date and time.

Thanks,
Hitesh

Extremest wrote:
I have a bunch of dates in a couple different formats. I would like to
convert them to epoch. The dates are like this

Mon, 12 Jun 2006 09:18:22 GMT
12 Jun 2006 10:37:28 GMT

I can do this in perl easily with the Date::Manip module but don't know
how to do it in c#. Is there a way to do this or do I need to right
something to parse each date?


Jun 19 '06 #2

P: n/a
I don't need to do the current one. I need to do ones that are in the
above format. Is that possible?

Jun 19 '06 #3

P: n/a
OK I figured it out. Used datetime.parse to get it formatted then used
a little function to get the epoch.

Jun 19 '06 #4

P: n/a
Hi,
For that u can use below line for getting UTC/GMT time:-

DateTime dt = DateTime.UtcNow;

Thanks,
Hitesh


Extremest wrote:
OK I figured it out. Used datetime.parse to get it formatted then used
a little function to get the epoch.


Jun 19 '06 #5

P: n/a
Concatenate the string using whatever you find here:
http://msdn2.microsoft.com/en-us/lib...d4(d=ide).aspx

chanmm

"Extremest" <dn**********@charter.net> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
I have a bunch of dates in a couple different formats. I would like to
convert them to epoch. The dates are like this

Mon, 12 Jun 2006 09:18:22 GMT
12 Jun 2006 10:37:28 GMT

I can do this in perl easily with the Date::Manip module but don't know
how to do it in c#. Is there a way to do this or do I need to right
something to parse each date?

Jun 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.