Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

Basic JavaScript

JS Tutorial JS Introduction JS Where To JS Output

JS Syntax

JS Syntax JS Statements JS Comments JS Variables JS Let JS Const JS Types

JS Operators

JS Operators

JS If Else

JS If Conditions

JS Loops

JS Loops

JS Strings

JS Strings

JS Numbers

JS Numbers

JS Functions

JS Functions

JS Objects

JS Objects

JS Scope

JS Scope

JS Dates

JS Dates

JS Temporal

JS Temporal  New

JS Arrays

JS Arrays

JS Sets

JS Sets

JS Maps

JS Maps

JS Iterations

JS Loops

JS Math

JS Math

JS RegExp

JS RegExp

JS DataTypes

JS Data Types

JS Errors

JS Errors

JS Debugging

JS Debugging

JS Conventions

JS Style Guide

JS Reference

JS Statements

JS Projects

JS Projects New

JS Versions

JS 2026

JS HTML

JS HTML DOM JS Events

JS Advanced

JS Functions JS Objects JS Classes JS Asynchronous JS Modules JS Meta & Proxy JS Typed Arrays JS DOM Navigation JS Windows JS Web APIs JS AJAX JS JSON JS jQuery JS Graphics JS Examples JS Reference


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");
Try it Yourself »

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

Temporal Map

What You Will 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 Temporal.PlainDateTime

An PlainDateTime object can be created in several different ways:

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

Create a PlainDateTime with new

You can create a PlainDateTime object using new with parameters.

Example

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

In Temporal objects, months start at 1.

In the legasy 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");
Try it Yourself »

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 requires.


Create a PlainDateTime from Now

You can create a PlainDateTime object from current time.

Example

const now = Temporal.Now.plainDateTimeISO();
Try it Yourself »

Combine Date and Time

You can combine PlainDate and PlainTime to create a PlainDateTime.

Example

// Create a PlainDate object
const date = Temporal.PlainDate.from("2026-05-17");

// Create a PlainTime object

const time = Temporal.PlainTime.from("14:30");

// Convert into a PlainDateTime object
const dateTime = date.toPlainDateTime(time);
Try it Yourself »

Add or Subtract Time

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 });
Try it Yourself »


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)
Try it Yourself »

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");
Try it Yourself »

Temporal.PlainDateTime Methods

ConstructingDescription
from() Creates a PlainDateTime object from an object or a string
new Creates 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.

Example

const date = new Temporal.PlainDateTime(2026, 5, 1, 14, 30);
Try it Yourself »
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

Display All Properties

const date = new Temporal.PlainDateTime(2026, 5, 1, 14, 30);
Try it Yourself »

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

-->