bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/JavaScript/Objects, Classes, and Advanced Patterns
JavaScript•Objects, Classes, and Advanced Patterns

JavaScript PlainDateTime

The Temporal.PlainDateTime Object

The Temporal.PlainDateTime object is a pure date and time object .

It represents a calendar date and a wall-clock time with no time zone.

Example: 2026-05-07T14:30:00 .

Example

// Create a PlainDateTime object
const dateTime = Temporal.PlainDateTime.from("2026-05-17T14:30:00");

The T is a literal to separate the date from the time.

What You Should Learn

  • How to use JavaScript Temporal.PlainDateTime
  • How to work with date and time without a time zone
  • How to add and subtract dates
  • How to compare dates safely

PlainDateTime is useful when you need both date and time, but not time zone.

How to Create a PlainDateTime Object

An PlainDateTime object can be created in several different ways:

FromCode
Constructor (new)new Temporal.PlainDateTime()
ISO StringTemporal.PlainDateTime.from()
Now (current time)Temporal.Now.plainDateTimeISO()

Create a PlainDateTime with new

You can create a PlainDateTime object using the new constructor.

The constructor takes parameters like year, month, day, hours, and minutes.

Example

// Create a PlainDateTime object
const date = new Temporal.PlainDateTime(2026, 5, 17, 14, 30);

In Temporal objects, months start at 1.

In the legacy Date object, months start at 0.

Create a PlainDateTime from a String

You can create a PlainDateTime object from an ISO 8601 / RFC 9557 string .

Example

// Create a PlainDateTime object
const dateTime = Temporal.PlainDateTime.from("2026-05-17T10:00:00");

The T Between Date and Time?

The T is a literal to separate the date from the time.

You should read it as an abbreviation for Time .

It is the separator required by the ISO 8601 format .

Create a PlainDateTime from Now

You can create a PlainDateTime object from current time.

Example

const now = Temporal.Now.plainDateTimeISO();

Add or Subtract PlainDateTime

You can safely add or subtract time.

The original value does not change.

Example

// Create a PlainDateTime object
const date = Temporal.PlainDateTime.from("2026-05-17T14:30:00");
// Add and subtract time
const earlier = dateTime.subtract({ minutes: 30 });
const later = dateTime.add({ hours: 2 });

When to Use PlainDateTime

  • Applications where time zone conversion is not required.
  • Local event scheduling.
  • Appointments without international time zone handling.
  • Forms that collect date and time.

Compare PlainDateTime Values

You can compare PlaneDateTime values using the equals() method.

Example

const d1 = Temporal.PlainDateTime.from("2026-05-17T14:30:00");
const d2 = Temporal.PlainDateTime.from("2026-05-17T14:30:00");
let result = d1.equals(d2)

Most (*) temporal objects have their own equals() method :

  • instant .equals( instant )
  • plaindate .equals( plaindate )
  • plaintime .equals( plaintime )
  • plainyearmonth .equals( plainyearmonth )
  • plainmonthday .equals( plainmonthday )
  • plaindateTime .equals( plaindatetime )
  • zoneddateTime .equals( zoneddtatime )

(*) Duration has not.

Learn More

JavaScript Temporal Compare

Convert to ZonedDateTime

A PlainDateTime object does not include time zone information.

You can convert it to a ZonedDateTime if needed.

Example

const dateTime = Temporal.PlainDateTime.from("2026-05-17T10:00:00");
const zoned = dateTime.toZonedDateTime("Europe/Oslo");

Compare PlainDateTime with Other Types

TypeMeaning
InstantExact Moment in UTC time
PlainDateTimePlaind Date and Time (No Timezone)
ZonedDateTimeLocal Date and Time (+ Time Zone)

Temporal.PlainDateTime Methods

ConstructingDescription
from()Creates a PlainDateTime object from an object or a string
newCreates a PlainDateTime object from parameters
Arithmetic
add()Returns a PlainDateTime with a duration added
subtract()Returns a PlainDateTime with a duration subtracted
round()Returns a PlainDateTime rounded to a given unit
Comparing
compare()Returns -1, 0, or 1 from comparing two dates
equals()Returns true if two PlainDateTime objects are identical
since()Returns the difference from another PlainDateTime
until()Returns the difference until another PlainDateTime
Converting
toPlainDate()Returns a PlainDate object with the date from this PlainDateTime
toPlainTime()Returns a PlainTime object with the time from this PlainDateTime
toZonedDateTime()Returns a ZonedDatetime object with this PlainDateTime in a time zone
with()Returns a PlainDateTime with specified fields modified
withCalendar()Returns a PlainDateTime with a different calendar system
withPlainTime()Returns a PlainDateTime with the time part replaced by a new time
Formatting
toJSON()Returns an RFC 9557 format string for JSON serialization
toLocaleString()Returns a language-sensitive representation of the date
toString()Returns an RFC 9557 format string representation of the date
valueOf()Throws an error to prevents temporals from being converted to primitives

Temporal.PlainDateTime Properties

The Temporal.PlainDateTime object has 22 properties of date information.

Display all PlainDateTime PropertiesExample

const date = new Temporal.PlainDateTime(2026, 5, 1, 14, 30);
PropertyDescription
calendarIDCalendar system identifier ("iso8601")
dayThe day as an integer (1-31)
dayOfWeekThe day of the week as an integer (1 = Monday)
dayOfYearThe ordinal day of the year
daysInMonthThe total number of days in that month
daysInWeekThe total number of days in that week
daysInYearThe total number of days in that year
eraThe era name of the calendar, if applicable ("gregory")
eraYearThe year within the era, if applicable
hourThe hour as an integer (0-23
inLeapYearA boolean indicating if the date falls in a leap year
microsecondThe microsecond as an integer (0-999)
millisecondThe millisecond as an integer (0-999)
minuteThe minute as an integer (0-59)
monthThe month as an integer (1-12)
monthCodeA calendar-specific string code for the month ("M01")
monthsInYearThe total number of months in that year
nanosecondThe nanosecond as an integer (0-999)
secondThe second as an integer (0-59)
weekOfYearThe week number within the year
yearThe year as an integer
yearOfWeekThe year that the week belongs to

Previous

JavaScript Display Objects

Next

JavaScript Function apply()

This chapter

Overview
123

Lessons

539m

Read time

1. JavaScript Objects2. JavaScript Temporal Tutorial3. JavaScript Loops4. JavaScript Advanced Functions5. JavaScript Objects6. JavaScript Temporal Intro7. JavaScript Iterables8. JavaScript Function Definitions9. JavaScript Object Properties10. JavaScript Temporal vs Date11. JavaScript Iterators12. JavaScript Callbacks13. JavaScript Object Methods14. JavaScript Temporal Duration15. JavaScript Generators16. The JavaScript this Keyword17. JavaScript this Keyword18. JavaScript Temporal Instant19. JavaScript Function call()20. JavaScript Display Objects21. JavaScript PlainDateTime22. JavaScript Function apply()23. JavaScript Object Constructors24. JavaScript Temporal PlainDate25. JavaScript Function bind()26. JavaScript PlainYearMonth27. Self-Invoking Functions28. JavaScript PlainMonthDay29. JavaScript Closures30. JavaScript Temporal PlainTime31. JavaScript Objects - Advanced32. JavaScript ZonedDateTime33. JavaScript Object Definitions34. JavaScript Temporal Now35. this in JavaScript Objects36. JS Temporal Arithmetic37. JavaScript Object Iterations38. JS Temporal Differences39. JavaScript Object Accessors40. JS Temporal Compare41. JavaScript Object Management42. JavaScript Temporal Conversion43. JavaScript Object Protection44. Temporal Display Formats45. JavaScript Object Prototypes46. JavaScript Temporal Mistakes47. JavaScript Classes48. Migrate from Date to Temporal49. JavaScript Class Inheritance50. Temporal Standards51. JavaScript Static Methods52. Asynchronous JavaScript53. Asynchronous Programming54. JavaScript Timeouts55. JavaScript Callbacks56. JavaScript Promises57. JavaScript async and await58. JavaScript fetch API59. Debugging Async JavaScript60. JavaScript Modules61. JavaScript Modules Export62. JavaScript Modules Import63. JS Module Namespace64. JavaScript Dynamic Modules65. JavaScript Meta Programming66. JavaScript Reflect67. JavaScript Proxy68. JavaScript Typed Arrays69. Typed Array Methods70. JavaScript ArrayBuffer71. JavaScript DataView72. JavaScript Atomics73. JavaScript HTML DOM Navigation74. JavaScript HTML DOM Elements (Nodes)75. JavaScript HTML DOM Collections76. JavaScript HTML DOM Node Lists77. JavaScript Window - The Browser Object Model78. JavaScript Window Screen79. JavaScript Window Location80. JavaScript Window History81. JavaScript Window Navigator82. JavaScript Popup Boxes83. JavaScript Timing Events84. JavaScript Cookies85. Web APIs - Introduction86. JavaScript Fetch API87. Web Geolocation API88. Web History API89. Pointer Events API90. Web Storage API91. JavaScript Validation API92. Web Workers API93. AJAX Introduction94. AJAX - The XMLHttpRequest Object95. AJAX - XMLHttpRequest96. AJAX - Server Response97. AJAX XML Example98. AJAX PHP Example99. AJAX ASP Example100. AJAX Database Example101. XML Applications102. JavaScript JSON103. JSON Syntax104. JSON vs XML105. JSON Data Types106. JSON.parse()107. JSON.stringify()108. JSON Object Literals109. JSON Array Literals110. JSON PHP111. JSON HTML112. JSONP113. JavaScript / jQuery DOM Selectors114. JavaScript / jQuery HTML Elements115. JavaScript / jQuery CSS Styles116. JavaScript / jQuery HTML DOM117. JavaScript Graphics118. HTML Canvas119. Plotly.js120. Chart.js121. Google Chart122. D3.js123. JavaScript Interview Preparation

On this page

The Temporal.PlainDateTime ObjectHow to Create a PlainDateTime ObjectCreate a PlainDateTime with newCreate a PlainDateTime from a StringThe T Between Date and Time?Create a PlainDateTime from NowAdd or Subtract PlainDateTimeWhen to Use PlainDateTimeCompare PlainDateTime ValuesConvert to ZonedDateTimeCompare PlainDateTime with Other TypesTemporal.PlainDateTime MethodsTemporal.PlainDateTime Properties