Zum Hauptinhalt springen Seitenleiste
Zum Inhaltsverzeichnis springen

    Format Date

    <pc-format-date> 1.0.0-alpha.1 experimental

    Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

    Formats a date/time using the specified locale and options.

    Localisation is handled by the browser’s Intl.DateTimeFormat API. No language packs are required.

    Edit

    The date attribute determines the date/time to use when formatting. It must be a string that Date.parse() can interpret or a Date object set via JavaScript. If omitted, the current date/time will be assumed.

    When using strings, avoid ambiguous dates such as 03/04/2024, which can be interpreted as 4 March 2024 or 3 April 2024 depending on the user’s browser and locale. Instead, always use a valid ISO 8601 date time string to ensure the date will be parsed properly by all clients.

    Demos#

    Date and time formatting#

    Formatting options are based on those found in the Intl.DateTimeFormat API. When formatting options are provided, the date/time will be formatted according to those values. When no formatting options are provided, a localised, numeric date will be displayed instead.

    Edit

    Hour formatting#

    By default, the browser will determine whether to use 12‐hour or 24‐hour time. To force one or the other, set the hour-format attribute to 12 or 24.

    Edit

    Localisation#

    Use the lang attribute to set the date/time formatting locale.

    Edit

    Eigenschaften#

    NameBeschreibungReflektiertStandard
    dateThe date/time to format. If not set, the current date and time will be used. When passing a string, it’s strongly recommended to use the ISO 8601 format to ensure timezones are handled correctly. To convert a date to this format in JavaScript, use date.toISOString().
    Typ: Date | string
    new Date()
    weekdayThe format for displaying the weekday.
    Typ: "narrow" | "short" | "long" | undefined
    eraThe format for displaying the era.
    Typ: "narrow" | "short" | "long" | undefined
    yearThe format for displaying the year.
    Typ: "numeric" | "2-digit" | undefined
    monthThe format for displaying the month.
    Typ: "numeric" | "2-digit" | "narrow" | "short" | "long" | undefined
    dayThe format for displaying the day.
    Typ: "numeric" | "2-digit" | undefined
    hourThe format for displaying the hour.
    Typ: "numeric" | "2-digit" | undefined
    minuteThe format for displaying the minute.
    Typ: "numeric" | "2-digit" | undefined
    secondThe format for displaying the second.
    Typ: "numeric" | "2-digit" | undefined
    timeZoneName
    time-zone-name
    The format for displaying the time.
    Typ: "short" | "long" | undefined
    timeZone
    time-zone
    The time zone to express the time in.
    Typ: string | undefined
    hourFormat
    hour-format
    The format for displaying the hour.
    Typ: "auto" | "12" | "24"
    "auto"
    updateComplete Ein schreibgeschütztes Promise, das erfüllt ist, sobald die Komponente fertig aktualisiert wurde.

    Erfahre mehr über Attribute und Eigenschaften.

    Importieren#

    Wenn du den Autoloader oder den Standard‐Loader nutzt, kannst du diesen Abschnitt überspringen. Falls du „Cherry Picking“ betreibst, kannst du die folgenden Snippets verwenden, um diese Komponente zu importieren.

    CDN (Skript‐Tag)CDN (Import)npm (Import)

    Um diese Komponente manuell vom CDN zu importieren, kopiere dieses Code‐Snippet und füge es in dein HTML ein.

    <script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.3/cdn/components/format-date/format-date.js"></script>

    Um diese Komponente manuell vom CDN zu importieren, kopiere dieses Code‐Snippet und füge es in deine JavaScript‐Datei ein.

    import "https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.3/cdn/components/format-date/format-date.js";

    Um diese Komponente manuell via npm zu importieren, kopiere dieses Code‐Snippet und füge es in deine JavaScript‐Datei ein.

    import "placer-toolkit/dist/components/format-date/format-date.js";

    Wir würden uns freuen, von dir zu hören. Bitte kontaktiere uns bei Fragen oder Anliegen, die du hast.

    Du kannst uns per E‐Mail unter placer.coc.reports+contact@gmail.com erreichen.

    Wir freuen uns darauf, von dir zu hören!

    Alles klar!
    Gefährliche Lande

    Ui! Du bist in die gefährlichen Lande von Placer Toolkit geraten. Version 0 ist veraltet und entspricht nicht den EU‐Datenschutzstandards, einschließlich DSGVO.

    Willst du die neuesten Kräfte, Sicherheit und Compliance? Bleib bei der aktuellen Version von Placer Toolkit!

    Ups! Aufladen!