VBS code to get the current time and date

Time:2022-3-1

Method 1 for obtaining the current date:

 

Copy codeThe code is as follows:

Currentdate1=date()
msgbox Currentdate1

 

Method 2 for obtaining the current date:

 

Copy codeThe code is as follows:

Currentdate2=year(Now)&”-“&Month(Now)&”-“&day(Now)
msgbox Currentdate2

 

Get current time:

 

Copy codeThe code is as follows:

CurrentTime=Hour(Now)&”:”&Minute(Now)&”:”&Second(Now)
M = “current time” & currenttime
msgbox m