Solved

How do you convert an epoch time to a standard Date/Time (m/d/y hh:mm:ss) format?

Posted on 2007-11-19
4
1,239 Views
Last Modified: 2008-02-01
I am in the process of writing a parsing utility that will take the data from our AVL system and populate it into an SQL database.  However, the one hang up that I am running into is that it stores the date and time in an epoch date format.  I have read this posting:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22100727.html

but I need it to go the other way.

How would I accomplish this?

Any help would be appreciated.  Thanks.
0
Comment
Question by:eric_krum
  • 3
4 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 20311707
Dim dtr As Date = dtEpoch.AddSeconds(1165449600)
        MsgBox("Windows Time: " + dtDate.ToString)
0
 
LVL 18

Expert Comment

by:armoghan
ID: 20311730
and to format
MsgBox("Windows Time: " + dtr.ToString("M/d/y hh:mm:ss", (New Globalization.CultureInfo("en-US")).DateTimeFormat))
0
 

Author Comment

by:eric_krum
ID: 20311977
I have taken the code that you supplied and modified it as follows:

Dim dtEpoch As Date

        Dim dtr As Date = dtEpoch.AddSeconds(1195369198)
        MsgBox("Windows Time: " + dtr.ToString)
        MsgBox("Windows Time: " + dtr.ToString("M/d/y hh:mm:ss", (New Globalization.CultureInfo("en-US")).DateTimeFormat))

However, the output has the correct M/D but the year and the time are off.  Am I missing something?
0
 
LVL 18

Accepted Solution

by:
armoghan earned 250 total points
ID: 20312117
Following would be Complete code.
as 1165449600 stands for 12/07/2006 so time would be 12:00:00 AM
  Dim dtEpoch As Date = "1/1/1970"
     Dim dtr As Date = dtEpoch.AddSeconds(1165449600)
        MsgBox("Windows Time: " + dtr.ToString("MM/dd/yyyy hh:mm:ss tt", (New Globalization.CultureInfo("en-US")).DateTimeFormat))
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get size of each directory on each mapped drive 5 36
Error handling in asp.net site 5 34
VB.NET 2008 - SQL Timeout 9 34
Passing data between Forms 3 20
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question