Found the following interesting discussion in the Newsgroups:
| DateDiff and Javascript .getTime methods by:Shane Saunders | |
| I trying to make a sub that works like Javascripts .getTime method. It work ok, but it does not should the time in it. The last numbers should be the time, but they are all zeros. Can anyone help me on this. here is the code i used. From reading i also seen that the getTime time starts on 01/01/1970 12am. I need to have this in Millsecond. VB.net Code: Dim days As Long Dim date1970 As Date = "#1/1/1970 12:00:00 AM#" Dim datenow As Date = Date.Now Dim mseconds As Long = 60 * 60 * 24 * 1000 days = DateDiff(DateInterval.DayOfYear, date1970, datenow) days = days * mseconds Label1.Text = days Output: 6/6/2004 10:02:35 AM 1086480000000 JavaScript Code: var uniquej = new Date(); var uniquei = "?"+uniquej.getTime(); document.write(uniquej) document.write("<br>") document.write(uniquei) Output: Sun Jun 6 10:00:20 PDT 2004 ?1086541220672 The outputs are almost the same, but i need them to the same. Is there a way to run that javascript code in vb.net and just pass the value back a variable? Shane | |
| Reply: by:The Grim Reaper | |
| This should help; Dim milliseconds As Double Dim date1970 As New Date(70, 1, 1, 12, 0, 0) milliseconds = DateTime.Now.Subtract(date1970).TotalMilliseconds() Label1.Text = milliseconds.ToString Try putting Option Strict On at the top of your code module - it helps with getting the right datatypes. ________________________________________ The Grim Reaper | |
| Reply: by:Shane Saunders | |
| The Grim Reaper, Thank you for your help. It work good, just had to change few thing. but the work the way i want it to.. Shane | |
Posted by Xander Zelders

0 Comments:
Post a Comment
<< Home