Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

best way to show seconds from 1970

Status
Not open for further replies.

gagz

Programmer
Nov 21, 2002
333
US
is there a way in .net (like in perl or php) to give a numeric time values as seconds or milliseconds from 1/1/1970?
 
cool... now, jsut because i found it, i'm doing:
Code:
Dim dtID As DateTime = DateTime.Now()
dr(0) = dtID.Ticks

do you think any is better than the other? Ticks is a large number since its from 0001 ( i think)
 
Well, datediff specifically looks at difference between two dates. Ticks, according to the help, is the number of 100 nanosecond intervals (the Windows clock tick time) between now and Jan1, 0001 (I've worked it out - it's correct). So depends what you want. I guess ticks is good for generating numbers which will not be repeated on a particular machine.
I've just done a little test and those numbers seem to be only accurate to the last but two significant figures, so I'm not sure if .net is really able to get it this precisely. You might want to do a test to see if it is going to cause you a problem.
Or you may prefer a different method of generating an ID. Is this for an RDBMS?



Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top