Home > Web Front-end > JS Tutorial > Use VBS to get the day before the current date and correct the output format

Use VBS to get the day before the current date and correct the output format

高洛峰
Release: 2017-01-16 10:21:10
Original
2131 people have browsed it

Method 1 to get the current date:

Currentdate1=date()
msgbox Currentdate1
Copy after login

Method 2 to get the current date:

Currentdate2=year(Now)&"-"&Month(Now)&"-"&day(Now)
msgbox Currentdate2
Copy after login

Additional one: If the date you want to get is preceded by 1 digit, add 0 in front, for example May 16, 2016, if the directory is 2016516, it is not as good as 20160516

ystr=year(Now)
mstr=Month(Now)
if len(mstr)<2 then mstr="0"&mstr
dstr=day(Now)
dateml=ystr&mstr&dstr
msgbox(dateml)
Copy after login

Get the current time:

CurrentTime=Hour(Now)&":"&Minute(Now)&":"&Second(Now)
m = "当前时间"& CurrentTime 
msgbox m
Copy after login

Use VBS under windows to get the day before the current date, and correct the output format

my_date1 = DateAdd("d",-1,date)

Function: Take the day before the current time (the current time is based on 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)

Function: Regardless of the time format set by the system (default is YYYY/M/D), modify the output time format to YYYY-MM-DD, and assign the result to the variable my_date2

View the output time:

msgbox my_date1
msgbox my_date2

The above script was tested under windows2003 and 2008 and passed

More uses VBS to get the day before the current date And for articles related to correcting the output format, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template