Date()
Object MethodsYou can use the Date object methods getDate()
, getMonth()
, and getFullYear()
to get the date, month and full-year from a Date object. Let's check out an example:
<script>
var d = new Date();
var date = d.getDate();
var month = d.getMonth() + 1; // Since getMonth() returns month from 0-11 not 1-12
var year = d.getFullYear();
var dateStr = date + "/" + month + "/" + year;
document.write(dateStr);
</script>
The getDate()
, getMonth()
, and getFullYear()
methods returns the date and time in the local timezone of the computer that the script is running on. If you want to get the date and time in the universal timezone just replace these methods with the getUTCDate()
, getUTCMonth()
, and getUTCFullYear()
respectivley, as shown in the following example:
<script>
var d = new Date();
var date = d.getUTCDate();
var month = d.getUTCMonth() + 1; // Since getUTCMonth() returns month from 0-11 not 1-12
var year = d.getUTCFullYear();
var dateStr = date + "/" + month + "/" + year;
document.write(dateStr);
</script>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Sending Telegram Notifications in Laravel
Telegram is a highly customizable,...Laravel 8 Rate Limiting per IP address
Laravel provides variety of custom rate...Create Multilevel Nested Comment System in Laravel 7.x Example
Hey Artisan Hope you are doing well i...PHP - How to get filename from N-level file directories
In this tutorials we are share with you...Create CRUD using Ajax with Example in PHP
In this tutorial, we learn to insert upd...