473,385 Members | 1,707 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,385 software developers and data experts.

Parsing UNIX timestamps with VB.NET

Would anyone happen to have any idea how to get a UNIX timestamp (AKA
epoch, or number of seconds since Jan 1st 1970) into a VB.NET datetime
type? I have a legacy application I'm trying to port and all the dates
and times are stored in the UNIX format..

Thanks!

--
- Mitchell Vincent
Nov 21 '05 #1
3 8094
Just add seconds in the epoch date

dim dt as Date = #1/1/1970#.AddSeconds(10327314*19)
or
dim dt as Date = new System.DateTime (1970,1,1).AddSeconds(10327314*19)

P.S.where 10327314*19 is the epoch seconds
P.S.code not compiled

HTH
rawCoder
Nov 21 '05 #2
In article <Ol**************@TK2MSFTNGP12.phx.gbl>, Mitchell Vincent wrote:
Would anyone happen to have any idea how to get a UNIX timestamp (AKA
epoch, or number of seconds since Jan 1st 1970) into a VB.NET datetime
type? I have a legacy application I'm trying to port and all the dates
and times are stored in the UNIX format..

Thanks!

--
- Mitchell Vincent


So, your dates are stored as seconds since the epoch? Then you should
be able to do something like:

Private ReadOnly EPOCH As Date = New Date (1970, 1, 1)

Dim theDate As Date = EPOCH.AddSeconds (SecondsSinceEpoch)

--
Tom Shelton [MVP]
Nov 21 '05 #3
Tom Shelton wrote:
In article <Ol**************@TK2MSFTNGP12.phx.gbl>, Mitchell Vincent wrote:
Would anyone happen to have any idea how to get a UNIX timestamp (AKA
epoch, or number of seconds since Jan 1st 1970) into a VB.NET datetime
type? I have a legacy application I'm trying to port and all the dates
and times are stored in the UNIX format..

Thanks!

--
- Mitchell Vincent

So, your dates are stored as seconds since the epoch? Then you should
be able to do something like:

Private ReadOnly EPOCH As Date = New Date (1970, 1, 1)

Dim theDate As Date = EPOCH.AddSeconds (SecondsSinceEpoch)


Doh. Now why didn't I think about that..

Thanks guys!!!

--
- Mitchell
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Sims | last post by:
Hi, I have a field in my DB that saves the date/time as a integer. I get the time on my server using the time() function. now, moving away from php and looking at (My)SQL only. If I use...
13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
7
by: lkrubner | last post by:
This might be an idiot question, but how do you group by timestamps by date? I mean, given a large number of timestamps, spanning many months, how do grab them and say how many are from each day?...
0
by: Casey | last post by:
Hi! I found several resources describing how to convert the UNIX timestamp to a readable date, however I need to convert a date into a UNIX timestamp. For instance, I'm writing a program that will...
2
by: In. Martin Prášek | last post by:
I I read the documentation well (PG 7.3.3 ) , i see that there is not a native support for data type UNIX TIMESTAMP and "unix timestamp expressed as microseconds" ie there it is impossible...
2
by: John Reese | last post by:
Hi. >>> import time, calendar, datetime >>> n= 1133893540.874922 >>> datetime.datetime.fromtimestamp(n) datetime.datetime(2005, 12, 6, 10, 25, 40, 874922) >>> lt= _ >>>...
2
by: Luis P. Mendes | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I've inserted a couple hundred rows in a table in Postgres via psycopg2. The first field of each row is a certain unix time (since epoch)...
4
by: David T. Ashley | last post by:
I'm writing a large PHP application that might still be in service in 2037. What will happen to PHP and Unix time ... will there be a version of PHP written for 32-bit platforms that uses 64-bit...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.