--- title: Date.prototype.setDate() | دالة تعيين التاريخ slug: Web/JavaScript/Reference/Global_Objects/Date/setDate tags: - التاريخ - النموذج المبدئي - جافاسكربت - طريقة - مرجع translation_of: Web/JavaScript/Reference/Global_Objects/Date/setDate ---
دالة setDate() تقوم بتعين يوم من الـ {{jsxref("Date")}} المحدد نسبه إلي الشهر المحدد.
dateObj.setDate(
dayValue [رقم اليوم])
dayValue
setDate(15)
.عدد المللي ثانية بين تاريخ 1 يناير 1970 00:00:00 UTC والتاريخ المحدد (يتغير الـ {{jsxref("Date")}} أيضا بتغير المكان [المنطقة الزمنية]).
إذا كان dayValue [رقم اليوم]
خارج نطاق قيم الشهر المحدد لهذا التاريخ، فأن دالة setDate()
ستقوم بتحديد الـ {{jsxref("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 |
---|---|---|
{{SpecName('ES1')}} | {{Spec2('ES1')}} | Initial definition. Implemented in JavaScript 1.0. |
{{SpecName('ES5.1', '#sec-15.9.5.36', 'Date.prototype.setDate')}} | {{Spec2('ES5.1')}} | |
{{SpecName('ES6', '#sec-date.prototype.setdate', 'Date.prototype.setDate')}} | {{Spec2('ES6')}} | |
{{SpecName('ESDraft', '#sec-date.prototype.setdate', 'Date.prototype.setDate')}} | {{Spec2('ESDraft')}} |
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.
{{Compat("javascript.builtins.Date.setDate")}}