new Date()
ﻩﺪﻧﺯﺎﺳ.ﺪﻧﻮﺷ ﯽﻣ ﺩﺎﺠﯾﺍ new Date()
ﺎﺑ ﺦﯾﺭﺎﺗ ءﺎﯿﺷﺍ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭ
new Date()
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﯽﻠﻌﻓ ﻥﺎﻣﺯ ﻭ ﺦﯾﺭﺎﺗ ﺎﺑ ﺍﺭ ﺦﯾﺭﺎﺗ
const date = new Date();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>Using new Date()</h2>
<p>Create a new date object with the current date and time:</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d;
</script>
</body>
</html>
(YYY) ﯽﻤﻗﺭ ﺭﺎﻬﭼ ﺩﺪﻋ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﻝﺎﺳ ﺖﻓﺎﯾﺭﺩ
(11-0) ﺩﺪﻋ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﻩﺎﻣ ﺖﻓﺎﯾﺭﺩ
(31-1) ﺩﺪﻋ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺯﻭﺭ ﺖﻓﺎﯾﺭﺩ
ﻪﺘﻔﻫ ﺯﻭﺭ (6-0) ﺪﯿﻨﮐ ﺖﻓﺎﯾﺭﺩ ﺩﺪﻋ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ
(0-23)/>ﺖﻋﺎﺳ ﺖﻓﺎﯾﺭﺩ
(0-59)/>ﻪﻘﯿﻗﺩ ﺖﻓﺎﯾﺭﺩ
(0-59)/>ﻪﯿﻧﺎﺛ ﺖﻓﺎﯾﺭﺩ
(0-999)/>ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ ﺖﻓﺎﯾﺭﺩ
(1970 ﻪﯾﻮﻧﺍﮊ 1 ﺯﺍ ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ) ﻥﺎﻣﺯ ﺖﻓﺎﯾﺭﺩ
.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﯽﻠﺤﻣ ﻥﺎﻣﺯ ﻻﺎﺑ ﺖﻓﺎﯾﺭﺩ ﯼﺎﻫ ﺵﻭﺭ
ﯽﻧﺎﻬﺟ ﻥﺎﻣﺯ (UTC) ﺖﺳﺍ ﻩﺪﺷ ﺖﺒﺛ ﻪﺤﻔﺻ ﻦﯾﺍ ﻦﯿﯾﺎﭘ ﺭﺩ.
.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺩﻮﺟﻮﻣ ﺦﯾﺭﺎﺗ ءﺎﯿﺷﺍ ﺯﺍ ﺍﺭ ﺕﺎﻋﻼﻃﺍ get ﯼﺎﻫﺪﺘﻣ
.ﺖﺴﯿﻧ "ﺍﺮﺟﺍ ﻝﺎﺣ ﺭﺩ" "ﺖﻋﺎﺳ" .ﺖﺳﺍ ﺖﺑﺎﺛ ﻥﺎﻣﺯ ،ﺦﯾﺭﺎﺗ ءﯽﺷ ﺭﺩ
.ﺖﺴﯿﻧ ﻥﺎﺴﮑﯾ ﯽﻠﻌﻓ ﻥﺎﻣﺯ ﺎﺑ ﺦﯾﺭﺎﺗ ءﯽﺷ ﺭﺩ ﻥﺎﻣﺯ
getFullYear()
ﺵﻭﺭ:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﯽﻤﻗﺭ ﺭﺎﻬﭼ ﺩﺪﻋ ﮏﯾ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﮏﯾ ﻝﺎﺳ getFu
const d = new Date("2021-03-25");
d.getFullYear();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getFullYear() Method</h2>
<p>Return the full year of a date object:</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25")
document.getElementById("demo").innerHTML = d.getFullYear();
</script>
</body>
</html>
const d = new Date();
d.getFullYear();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getFullYear() Method</h2>
<p>Return the full year of a date object:</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getFullYear();
</script>
</body>
</html>
.ﺪﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ()getYear ﺩﺭﺍﺪﻧﺎﺘﺳﺍ ﺮﯿﻏ ﺪﺘﻣ ﺯﺍ ﺖﺳﺍ ﻦﮑﻤﻣ ﯽﻤﯾﺪﻗ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺪﮐ
()getYear ﺪﻧﺍﺩﺮﮔﺮﺑ ﺍﺭ ﯽﻤﻗﺭ 2 ﻝﺎﺳ ﮏﯾ ﺖﺳﺍ ﺭﺍﺮﻗ.
getYear() ﺪﯿﻨﮑﻧ ﻩﺩﺎﻔﺘﺳﺍ ﻥﺁ ﺯﺍ .ﺖﺳﺍ ﻩﺪﺷ ﺥﻮﺴﻨﻣ!
getMonth()
ﺵﻭﺭ.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ (11-0) ﺩﺪﻋ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﻩﺎﻣ ... ،ﺖﺳﺍ 1 ﻩﺭﺎﻤﺷ ﻪﯾﺭﻮﻓ ،0 ﻩﺭﺎﻤﺷ ﻩﺎﻣ ﻪﯾﻮﻧﺍﮊ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ .ﺖﺳﺍ 11 ﻩﺭﺎﻤﺷ ﻩﺎﻣ ﺮﺒﻣﺎﺳﺩ ،ﺖﯾﺎﻬﻧ ﺭﺩ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻡﺎﻧ ﻥﺍﻮﻨﻋ ﻪﺑ ﻩﺎﻣ ﻥﺪﻧﺍﺩﺮﮔﺮﺑ ﯼﺍﺮﺑ ﺎﻫ ﻡﺎﻧ ﺯﺍ ﯼﺍ ﻪﯾﺍﺭﺁ ﺯﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ (31-1) ﺩﺪﻋ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﺯﻭﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ (23-0) ﺩﺪﻋ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﮏﯾ ﺕﺎﻋﺎﺳ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ (59-0) ﺩﺪﻋ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﮏﯾ ﻪﻘﯿﻗﺩ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ (59-0) ﺩﺪﻋ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﯼﺎﻫ ﻪﯿﻧﺎﺛ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ (0-999) ﺩﺪﻋ ﻥﺍﻮﻨﻋ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﮏﯾ ﯼﺎﻫ ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧgetMonth()
ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
ﺎﻫ ﻝﺎﺜﻣ
const d = new Date("2021-03-25");
d.getMonth();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getMonth() Method</h2>
<p>Return the month of a date as a number from 0 to 11.</p>
<p>To get the correct month number, you must add 1:</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");
document.getElementById("demo").innerHTML = d.getMonth() + 1;
</script>
</body>
</html>
const d = new Date();
d.getMonth();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getMonth() Method</h2>
<p>Return the month of a date as a number from 0 to 11.</p>
<p>To get the correct month number, you must add 1:</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getMonth() + 1;
</script>
</body>
</html>
ﺪﯿﺷﺎﺑ ﻪﺘﺷﺍﺩ ﻪﺟﻮﺗ
ﺎﻫ ﻝﺎﺜﻣ
const months = ["January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"];
const d = new Date("2021-03-25");
let month = months[d.getMonth()];
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>JavaScript getMonth()</h2>
<p>Return the month as a number.</p>
<p>You can use an array of names to return the month as a name:</p>
<p id="demo"></p>
<script>
const months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
const d = new Date("2021-03-25");
let month = months[d.getMonth()];
document.getElementById("demo").innerHTML = month;
</script>
</body>
</html>
const months = ["January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"];
const d = new Date();
let month = months[d.getMonth()];
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>JavaScript getMonth()</h2>
<p>Return the month as a number.</p>
<p>You can use an array of names to return the month as a name:</p>
<p id="demo"></p>
<script>
const months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
const d = new Date();
let month = months[d.getMonth()];
document.getElementById("demo").innerHTML = month;
</script>
</body>
</html>
getDate()
ﺵﻭﺭgetDate()<
ﺎﻫ ﻝﺎﺜﻣ
const d = new Date("2021-03-25");
d.getDate();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getDate() Method</h2>
<p>Return the day of a date as a number (1-31):</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");
document.getElementById("demo").innerHTML = d.getDate();
</script>
</body>
</html>
const d = new Date();
d.getDate();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getDate() Method</h2>
<p>Return the day of a date as a number (1-31):</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getDate();
</script>
</body>
</html>
getHours()
ﺵﻭﺭgetHours(
ﺎﻫ ﻝﺎﺜﻣ
const d = new Date("2021-03-25");
d.getHours();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getHours() Method</h2>
<p>Return the hours of a date as a number (0-23):</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");document.getElementById("demo").innerHTML = d.getHours();
</script>
</body>
</html>
const d = new Date();
d.getHours();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getHours() Method</h2>
<p>Return the hours of a date as a number (0-23):</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getHours();
</script>
</body>
</html>
getMinutes()
ﺵﻭﺭgetMinute
ﺎﻫ ﻝﺎﺜﻣ
const d = new Date("2021-03-25");
d.getMinutes();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getMinutes() Method</h2>
<p>Returns the minutes of a date as a number (0-59):</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");
document.getElementById("demo").innerHTML = d.getMinutes();
</script>
</body>
</html>
const d = new Date();
d.getMinutes();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getMinutes() Method</h2>
<p>Returns the minutes of a date as a number (0-59):</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getMinutes();
</script>
</body>
</html>
getSeconds()
ﺵﻭﺭgetSeco
ﺎﻫ ﻝﺎﺜﻣ
const d = new Date("2021-03-25");
d.getSeconds();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getSeconds() Method</h2>
<p>Return the seconds of a date as a number (0-59):</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");
document.getElementById("demo").innerHTML = d.getSeconds();
</script>
</body>
</html>
const d = new Date();
d.getSeconds();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getSeconds() Method</h2>
<p>Return the seconds of a date as a number (0-59):</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getSeconds();
</script>
</body>
</html>
getMilliseconds()
ﺵﻭﺭ ﺎﻫ ﻝﺎﺜﻣ
const d = new Date("2021-03-25");
d.getMilliseconds();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getMilliseconds() Method</h2>
<p>Return the milliseconds of a date as a number (0-999):</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");
document.getElementById("demo").innerHTML = d.getMilliseconds();
</script>
</body>
</html>
const d = new Date();
d.getMilliseconds();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getMilliseconds() Method</h2>
<p>Return the milliseconds of a date as a number (0-999):</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getMilliseconds();
</script>
</body>
</html>
getDay()
ﺵﻭﺭ.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ (6-0) ﺩﺪﻋ ﺕﺭﻮﺻ ﻪﺑ ﺍﺭ ﺦﯾﺭﺎﺗ ﮏﯾ ﻪﺘﻔﻫ ﺯﻭﺭ getDay(
.ﺖﺳﺍ ﻪﺒﻨﺸﮑﯾ (0 ﺯﻭﺭ) ﻪﺘﻔﻫ ﺯﻭﺭ ﻦﯿﻟﻭﺍ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ
.ﺪﻨﻧﺍﺩ ﯽﻣ ﻪﺒﻨﺷﻭﺩ ﺍﺭ ﻪﺘﻔﻫ ﺯﻭﺭ ﻦﯿﻟﻭﺍ ﻥﺎﻬﺟ ﯼﺎﻫﺭﻮﺸﮐ ﺯﺍ ﯽﺧﺮﺑ
const d = new Date("2021-03-25");
d.getDay();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getDay() Method</h2>
<p>Return the weekday as a number:</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");
document.getElementById("demo").innerHTML = d.getDay();
</script>
</body>
</html>
const d = new Date();
d.getDay();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getDay() Method</h2>
<p>Return the weekday as a number:</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getDay();
</script>
</body>
</html>
:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻡﺎﻧ ﻥﺍﻮﻨﻋ ﻪﺑ ﻪﺘﻔﻫ ﯼﺎﻫﺯﻭﺭ ﻥﺪﻧﺍﺩﺮﮔﺮﺑ ﯼﺍﺮﺑ getDa
const days = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
const d = new Date("2021-03-25");
let day = days[d.getDay()];
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getDay() Method</h2>
<p>Return the weekday as a number.</p>
<p>You can use an array of names to return the weekday as a name:</p>
<p id="demo"></p>
<script>
const days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
const d = new Date("2021-03-25");
let day = days[d.getDay()];
document.getElementById("demo").innerHTML = day;
</script>
</body>
</html>
const days = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
const d = new Date();
let day = days[d.getDay()];
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getDay() Method</h2>
<p>Return the weekday as a number.</p>
<p>You can use an array of names to return the weekday as a name:</p>
<p id="demo"></p>
<script>
const days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
const d = new Date();
let day = days[d.getDay()];
document.getElementById("demo").innerHTML = day;
</script>
</body>
</html>
getTime()
ﺵﻭﺭ:ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ 1970 ﻪﯾﻮﻧﺍﮊ ﻝﻭﺍ ﺯﺍ ﺍﺭ ﺎﻫ ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ ﺩﺍﺪﻌﺗ getT
const d = new Date("1970-01-01");
d.getTime();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getTime() Method</h2>
<p></p>
<p>Return the number of milliseconds since midnight January 1, 1970:</p>
<p id="demo"></p>
<script>
const d = new Date("1970-01-01");
document.getElementById("demo").innerHTML = d.getTime();
</script>
</body>
</html>
const d = new Date("2021-03-25");
d.getTime();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getTime() Method</h2>
<p></p>
<p>Return the number of milliseconds since midnight January 1, 1970:</p>
<p id="demo"></p>
<script>
const d = new Date("2021-03-25");
document.getElementById("demo").innerHTML = d.getTime();
</script>
</body>
</html>
const d = new Date();
d.getTime();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getTime() Method</h2>
<p></p>
<p>Return the number of milliseconds since midnight January 1, 1970:</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getTime();
</script>
</body>
</html>
Date.now()
ﺵﻭﺭDate.now()
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ 1970 ﻪﯾﻮﻧﺍﮊ ﻝﻭﺍ ﺯﺍ ﺍﺭ ﺎﻫ ﻪﯿﻧﺎ
let ms = Date.now();
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The Date.now() Method</h2>
<p>Return the current date/time in milliseconds since January 1, 1970:</p>
<p id="demo"></p>
<script>
const date = Date.now();
document.getElementById("demo").innerHTML = date;
</script>
</body>
</html>
:1970/01/01 ﺯﺍ ﺲﭘ ﯼﺎﻬﻟﺎﺳ ﺩﺍﺪﻌﺗ ﻪﺒﺳﺎﺤﻣ
const minute = 1000 * 60;
const hour = minute * 60;
const day = hour * 24;
const year = day * 365;
let years = Math.round(Date.now() / year);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>Using Date.now()</h2>
<p>Calculate the number of years since January 1, 1970:</p>
<p id="demo"></p>
<script>
// Calculate milliseconds in a year
const minute = 1000 * 60;
const hour = minute * 60;
const day = hour * 24;
const year = day * 365;
// Divide Date.now() with a year
let years = Math.round(Date.now() / year);
document.getElementById("demo").innerHTML = years;
</script>
</body>
</html>
Date.now()
ﯽﺷ ﺯﺍ ﺖﺑﺎﺛ ﺵﻭﺭ ﮏﯾ Date ﺖﺳﺍ.
.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ myDate.now()
ﺪﻨﻧﺎﻣ ﺦﯾﺭﺎﺗ ءﯽﺷ ﮏﯾ ﺭﺩ ﺍﺭ
.ﺖﺳﺍ Date.now()
ﻪﺸﯿﻤﻫ ﻮﺤﻧ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ UTC ﺦﯾﺭﺎﺗ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ UTC ﻝﺎﺳ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ UTC ﻩﺎﻣ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ UTC ﺯﻭﺭ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ UTC ﺖﻋﺎﺳ
ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ UTC ﻪﻘﯿﻗﺩ
UTC ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻪﯿﻧﺎﺛ
UTC ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻪﯿﻧﺎﺛ ﯽﻠﯿﻣ
UTC methods use UTC time (Coordinated Universal Time).
UTC time is the same as GMT (Greenwich Mean Time).
The difference between Local time and UTC time can be up to 24 hours.
getTimezoneOffset()
ﺵﻭﺭ.ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ (ﻪﻘﯿﻗﺩ ﺪﻨﭼ ﺭﺩ) ﺍﺭ ﺕﻭﺎﻔﺗ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﯿﻨﮐ ﻪﻌﺟﺍﺮﻣ ﺎﻣ ﻪﺑ ،ﺦﯾﺭﺎﺗ ﻞﻣﺎﮐ ﻊﺟﺮﻣ ﮏﯾ ﯼﺍﺮﺑ .ﻞﻣﺎﮐ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺦﯾﺭﺎﺗ ﻊﺟﺮﻣ ﻭ ﺦﯾﺭﺎﺗ ﯼﺎﻫ ﯽﮔﮋﯾﻭ ﻡﺎﻤﺗ ﺯﺍ ﯽﯾﺎﻫ ﻪﻧﻮﻤﻧ ﻭ ﺕﺎﺤﯿﺿﻮﺗ ﯼﻭﺎﺣ ﻊﺟﺮﻣgetTimezoneOffset()
ﻝﺎﺜﻣ
let diff = d.getTimezoneOffset();
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Dates</h1>
<h2>The getTimezoneOffset() Method</h2>
<p>The time zone difference in minutes is:</p>
<p id="demo"></p>
<script>
const d = new Date();
document.getElementById("demo").innerHTML = d.getTimezoneOffset();
</script>
</body>
</html>
ﻞﻣﺎﮐ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺦﯾﺭﺎﺗ ﻊﺟﺮﻣ