Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
VB.Net: Add time to a date (hours, minutes, seconds)
From Wiki
In .Net you can easily make a date and add hours, minutes and seconds to it.
- Module Module1
- Sub Main()
- Dim _Date As New Date(2008, 6, 12, 12, 12, 12)
- Console.WriteLine("begin")
- Console.WriteLine(_Date.ToString("dd/MM/yyyy HH/mm/ss"))
- _Date = _Date.AddHours(10)
- Console.WriteLine("added 10 hours")
- Console.WriteLine(_Date.ToString("dd/MM/yyyy HH/mm/ss"))
- _Date = _Date.AddMinutes(10)
- Console.WriteLine("added 10 minutes")
- Console.WriteLine(_Date.ToString("dd/MM/yyyy HH/mm/ss"))
- _Date = _Date.AddSeconds(10)
- Console.WriteLine("added 10 seconds")
- Console.WriteLine(_Date.ToString("dd/MM/yyyy HH/mm/ss"))
- _Date = _Date.Add(New TimeSpan(10, 10, 0, 10, 0))
- Console.WriteLine("added 10 days, 10 hours and 10 seconds with timespan")
- Console.WriteLine(_Date.ToString("dd/MM/yyyy HH/mm/ss"))
- Console.ReadLine()
- End Sub
- End Module
This will give as result.




LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.