var date_format = new Date(); document.write(innerHTML = date_format.getMonth()+'/'+ date_format.getDate()+'/'+date_format.getFullYear());
So You can see below here is your code as you know the date format. In this code create an object for date and then stored these abject a variable.
Following are the table of contents
- Format dd-mmm-yyyy
- Date output format
- Date format yyyy-mm-dd hh mm ss
- Date to string format
Date format dd-mmm-yyyy
- getMonth() ( We are using for month )
- getDate() ( Also using get-date )
- getFullYear() (show for year )
var date_format = new Date(); document.write(innerHTML = date_format.getMonth()+'-'+ date_format.getDate()+'-'+date_format.getFullYear());
To create a dating format script with this format an example. So there are uses id for showing output format with the help of Html structure. Otherwise, Below can see the full script code and define it.
var date_format=new Date();document.getElementById("date").innerHTML=date_format.getMonth()+'/'+date_format.getDate()+'/'+date_format.getFullYear();
Finally, this format is the same but include hours, minute, and second. Code is the same and syntax the same function insert in this code you can see below example about it.
var date_format=new Date();document.getElementById("date").innerHTML=date_format.getMonth()+'/'+date_format.getDate()+'/'+date_format.getFullYear()+'-'+date_format.getHours()+'-'+date_format.getMinutes()+'-'+date_format.getSeconds();
Output in this format
Also, You can make it all format as you like we already that format copy and paste on your page. This is only a rearranged format check it below.
document.getElementById("date").innerHTML = date_format.getMonth()+'/'+ date_format.getDate()+'/'+date_format.getFullYear();
In this case, we are providing code in function because whenever we use this code so only coll function for date format through this.
we can create more function and apply anywhere when you need. Now we give you some example about function with the code lets starts to see it.
Here is code
Afterward, We are discussing all the topic in this article hope you understand. If you have any other issue and queries relative to this and so on you can ask the comment section.
We sure have to solve as you want with us. You can read more articles with us:- WordPress custom page template