This article mainly introduces how to use VBS to get the previous day of the current date and correct the output format. For more information about how to obtain the current date, see method 1:
Currentdate1=date()msgbox Currentdate1
Method 2:
Currentdate2=year(Now)&"-"&Month(Now)&"-"&day(Now)msgbox Currentdate2
Add one: if you want to get a date that is preceded by one-digit prefix with 0, for example, 2016516, it would be better if the directory is 20160516
ystr=year(Now)mstr=Month(Now)if len(mstr)<2 then mstr="0"&mstrdstr=day(Now)dateml=ystr&mstr&dstrmsgbox(dateml)
Get current time:
CurrentTime = Hour (Now) & ":" & Minute (Now) & ":" & Second (Now) m = "Current Time" & CurrentTime msgbox m
In windows, use VBS to retrieve the previous day of the current date and correct the output format.
My_date1 = DateAdd ("d",-1, date)
Purpose: Take the previous day of the current time (the current time is subject to the system time) and assign the result to the variable my_date1
My_date2 = DatePart ("yyyy", my_date1) & "-" & Right ("0" & DatePart ("m", my_date1), 2) & "-" & Right ("0" & DatePart ("d", my_date1), 2)
Purpose: Modify the output time format to YYYY-MM-DD without considering the system-set time format (default: YYYY/M/D) and assign the result to the variable my_date2
View the Output Time:
Msgbox my_date1
Msgbox my_date2
The above scripts are successfully tested in Windows 2008 and.
For more information about how to use VBS to get the previous day of the current date and correct the output format, see PHP!