hyTags
HomeHome DocumentationDocumentation

date-to-string

Converts a date to a string using an optional format
Parameter
Type
Description
self
Date
The date to convert
format
String?
The format string. Supports YYYY, YY, MM, M, DD, D. Use 'text' for literals. Optional, defaults to YYYY-MM-DD.
return
string
The formatted date string
Test Case:Convert date to string
    <div></div>
    
    <date-new year="2024" month="6" day="15">
    <date-to-string>
    <assert-equal value="2024-06-15" type="string">
    
    👆 Try to change something!
  • Test Case:Convert date with single digit month
      <div></div>
      
      <date-new year="2024" month="1" day="5">
      <date-to-string>
      <assert-equal value="2024-01-05" type="string">
      
      👆 Try to change something!
    • Test Case:Format DD.MM.YYYY
        <div></div>
        
        <date-new year="2024" month="6" day="15">
        <date-to-string format="DD.MM.YYYY">
        <assert-equal value="15.06.2024" type="string">
        
        👆 Try to change something!
      • Test Case:Format without padding D/M/YY
          <div></div>
          
          <date-new year="2024" month="6" day="5">
          <date-to-string format="D/M/YY">
          <assert-equal value="5/6/24" type="string">
          
          👆 Try to change something!
        • Test Case:Format MM/DD/YYYY
            <div></div>
            
            <date-new year="2024" month="6" day="15">
            <date-to-string format="MM/DD/YYYY">
            <assert-equal value="06/15/2024" type="string">
            
            👆 Try to change something!
          • Test Case:Format with literal string
              <div></div>
              
              <date-new year="2024" month="6" day="15">
              <date-to-string format="D'. 'M'. 'YYYY">
              <assert-equal value="15. 6. 2024" type="string">
              
              👆 Try to change something!
            • Test succeeded Test failed