Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2016. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Time Demo
- '
- ' Author: Joseph L. Bolen
- ' Date Created: 02 MAR 2016
- '
- ' Description: Show how to declare and use only the time portion of the Date or DateTime
- ' datatypes.
- '
- ' Documentation: http://pastebin.com/mVC6Cc3r
- '
- '-------------------------------------------------------------------------------------------
- Module TimeDemo
- Sub Main()
- ' Using the Date datatype normally...
- 'Dim aTime As Date = #yyyy-mm-dd hh:mm:ss# (Or #yyyy-mm-dd hh:mm:ss AM/PM#
- 'Dim aTime As Date = #2016-03-02 14:02:00# ' 3/2/2016 2:02:00 PM
- 'Dim aTime As Date = #0001-01-01 14:02:00# ' 1/1/0001 2:02:00 PM
- ' Using the Date datatype with only the time portion...
- ' (Defaults to 01 JAN 0001)
- 'Dim aTime As Date = #14:02# ' 1/1/0001 2:02:00 PM
- 'Dim aTime As Date = #2:02 PM# ' 1/1/0001 2:02:00 PM
- ' Using DateTime datatype normally ...
- 'Dim aTime As New DateTime(yyyy, hh, dd, hh, mm, ss)
- 'Dim aTime As New DateTime(2016, 3, 2, 14, 02, 0) ' 3/2/2016 2:02:00 PM
- Dim aTime As New DateTime(0001, 1, 1, 14, 02, 0) ' 1/1/0001 2:02:00 PM
- Console.WriteLine(aTime)
- Console.WriteLine(aTime.ToShortTimeString) ' 2:02 PM
- Console.WriteLine(aTime.ToLongTimeString) ' 2:02:00 PM
- Console.WriteLine(aTime.ToString("hh:mm tt")) ' 02:02 PM
- Console.ReadLine()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment