دالة setDate() تقوم بتعين يوم من الـ Date
المحدد نسبه إلي الشهر المحدد.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
بنية الجملة
dateObj.setDate(
dayValue [رقم اليوم])
المعاملات (Parameters)
dayValue
- يجب أن يكون عدد صحيح يمثل يوم من الشهر. علي سبيل المثال
setDate(15)
.
القيمة العائدة
عدد المللي ثانية بين تاريخ 1 يناير 1970 00:00:00 UTC والتاريخ المحدد (يتغير الـ Date
أيضا بتغير المكان [المنطقة الزمنية]).
الوصف
إذا كان dayValue [رقم اليوم]
خارج نطاق قيم الشهر المحدد لهذا التاريخ، فأن دالة setDate()
ستقوم بتحديد الـ Date
[اليوم] وفقاً لذلك. علي سبيل المثال، إذا تم تحديد dayValue [رقم اليوم]
إلي 0
فسيتم تعيين التاريخ إلي أخر يوم في الشهر السابق.
أمثلة
استخدام setDate()
var theBigDay = new Date(1962, 6, 7); // 1962-07-07
theBigDay.setDate(24); // 1962-07-24
theBigDay.setDate(32); // 1962-08-01
theBigDay.setDate(22); // 1962-08-22
theBigDay.setDate(0); // 1962-06-30
theBigDay.setDate(98); // 1962-10-06
theBigDay.setDate(-50); // 1962-08-09
الخصائص
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) The definition of 'Date.prototype.setDate' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Date.prototype.setDate' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Date.prototype.setDate' in that specification. |
Living Standard |
دعم المتصفحات
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.