add st nd rd th to date in batch -


i add suffix date's in batch program.

this belive work (if done proper) , need with!

if %date:~0,-8%==01 set "newdateday1=1st" if %date:~0,-8%==02 set "newdateday2=2nd" if %date:~0,-8%==03 set "newdateday3=3rd" if %date:~0,-8% gtr 4 set "newdateday4plus=th"

so sum need output this

21st of august 2017

instead of this

21-08-2017

as first looks way better in opinion :)

just use this:

@echo off  rem echo script based upon default date format ending dd/mm/yyyy rem echo "/" can usual separator , leading 0s included.  set "tod=%date%" set "dom=%tod:~-10,2%" set "moy=%tod:~-7,2%" set "yr=%tod:~-4%"  if not "%dom:~,1%"=="1" (     if "%dom:~-1%"=="1" set "das=%dom%st"     if "%dom:~-1%"=="2" set "das=%dom%nd"     if "%dom:~-1%"=="3" set "das=%dom%rd") if not defined das set "das=%dom%th" if "%das:~,1%"=="0" set "das=%das:~1%"  if not "%moy:~,1%"=="1" (     if "%moy:~-1%"=="1" set "mas=%moy%st"     if "%moy:~-1%"=="2" set "mas=%moy%nd"     if "%moy:~-1%"=="3" set "mas=%moy%rd") if not defined mas set "mas=%moy%th" if "%mas:~,1%"=="0" set "mas=%mas:~1%"  if not "%yr:~-2,1%"=="1" (     if "%yr:~-1%"=="1" set "yas=%yr%st"     if "%yr:~-1%"=="2" set "yas=%yr%nd"     if "%yr:~-1%"=="3" set "yas=%yr%rd") if not defined yas set "yas=%yr%th"  echo today %das% day of %mas% month of %yas% year  timeout -1 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -