0

So Im stuck here on my project in VB.Net . I wanted to make a user defined date time function that is not dependent on the system time Ive tried to search on the net but they only gave me how to print current system time. Any idea guys how to make a customized date time updating every seconds in other words real time .

any answers will be entertained thanks in advance.

  • "user defined date time function that is not dependent on the system time" - I have no idea what you mean. Please expand your question and include some code of what you have tried so far, otherwise it is likely to be closed – Matt Wilko Aug 18 '15 at 08:51

1 Answers1

0

You can save the value of Date.Now at the start of your application in a global variable:

Public StartDate As Date = Date.Now

Then you can calculate the current date in your arbitrary time scale, using the TimeSpan calculated from this starting date and the current date, at any point in your code:

Dim Elapsed As TimeSpan = Date.Now - StartDate
Dim NewDate As Date = ArbitraryStartDate + Elapsed

Choose ArbitraryStartDate to be any date you like with the Date constructor like

Dim ArbitraryStartDate As Date = New Date(1983, 05, 03)

enter image description here

Jens
  • 6,275
  • 2
  • 25
  • 51
  • Amazing . Thank you for your response I really appreciated it. – Robin Bernardo Aug 18 '15 at 08:52
  • @RobinBernardo No problem. Welcome to StackOverflow. You should however read this http://stackoverflow.com/tour and this http://stackoverflow.com/help/how-to-ask in order to improve the questions you ask, as this one wasn't entirely clear in the first place. – Jens Aug 18 '15 at 08:58
  • Im having trouble in setting the correct timezone. Because im implementing a system that uses time that is not dependent on the computers system time. – Robin Bernardo Aug 18 '15 at 09:13