Share via

vb.net | Date in more user friendly format

~OSD~ 2,206 Reputation points
2023-03-20T06:56:31.5433333+00:00

Hi,

is it possible to get the date in more user friendly?

Dim BIOSInfo As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_BIOS")

queryBIOS("ReleaseDate")

20221219000000.000000+000 Dim OSInfo As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_OperatingSystem")

queryOSInfo("InstallDate")

20220502080901.000000+060

Developer technologies | VB
0 comments No comments

Answer accepted by question author

LesHay 7,146 Reputation points
2023-03-20T11:25:42.16+00:00

Hi

OR,

		' From: https://stackoverflow.com/questions/170617/how-do-i-find-the-install-time-and-date-of-windows

		' Needs Imports System.Management
		Dim dtmInstallDate As DateTime
		Dim oSearcher As New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
		For Each oMgmtObj As ManagementObject In oSearcher.Get
			dtmInstallDate = ManagementDateTimeConverter.ToDateTime(CStr(oMgmtObj("InstallDate")))
		Next

Was this answer helpful?

2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 34,241 Reputation points Microsoft External Staff
    2023-03-20T09:13:29.58+00:00

    Hi, welcome to Microsoft Q&A. The specific format needs to refer to the motherboard manufacturer. The following code intercepts the part of the data before . to format the datetime.

            Dim formatString As String = "yyyyMMddHHmmss"
            Dim str As String = "20220502080901.000000+060"
            Dim dt As DateTime = DateTime.ParseExact(str.Split("+")(0), formatString, Nothing)
            MessageBox.Show(dt)
    

    Best Regards.
    Jiachen Li
    ----------
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.