473,403 Members | 2,270 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,403 software developers and data experts.

How to Convert a date and time to epoch?

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
5 5688
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ralph Freshour | last post by:
What's a good way to calculate the number of days between two dates in the following format: 2003-07-15 2003-08-02 I've looked at the PHP date functions but I'm still a bit lost...
3
by: Ralf Meuser | last post by:
Hi there, I get form a database time with the format : 'Jan 01 1900 06:00PM' I want to convert it to :HH:MM I tryed it with $heure=(date("H:i",strtotime($row)) but I get allways 20:55. even...
1
by: Sorisio, Chris | last post by:
Ladies and gentlemen, I've imported some data from a MySQL database into a Python dictionary. I'm attempting to tidy up the date fields, but I'm receiving a 'mx.DateTime.Error: cannot convert...
17
by: Terry Jolly | last post by:
New to C# ---- How do I convert a Date to int? In VB6: Dim lDate as long lDate = CLng(Date) In C#
1
by: Ryan Ramsey | last post by:
I am trying to convert a value returned from the date() function in php 5.0 to a format .NET can use. DateTime dt_now = DateTime.Now; DateTime dt_last = new DateTime(Convert.ToInt32(dkpLast));...
4
by: Holmsey | last post by:
Hi I have to convert am today's date and time (now) to a webservice. The example the web service gives was "1163313527144#" which comes out to 12/31/1969 06:00 PM. How do I convert a date to a 13...
2
by: Stefan Antonelli | last post by:
Hi, i have to convert several timestamps. The given format, eg "yyyy-mm-dd hh:mm:ss" has to be converted to an epoch string. Is there any proper way to do this? If not, i have to split the...
3
by: Lonifasiko | last post by:
Hi, I want to convert an UTC time to a Date object in Javascript. The UTC time we have is a string that looks like "1160720058.377452373" for example. I've done it in Java but I'm not able...
6
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.