Function formatDate

PHP's strftime-like date formatter. IMPORTANT: Use Intl.DateTimeFormat everywhere possible. Use this only if you are 100% sure you want to have given date format, not depending on any locale standards.

Important: this is work in progress. All locale-based values are not supported yet. Formats that heavily depend on locale won't ever be supported.

formatDate(Date.now(), "%Y-%m-%d %H:%M:%S"); // ie: "2024-06-26 14:23:45"
  • Parameters

    • date: number | Date
    • format: string
    • locale: string = "en-US"

    Returns string