hyTags
HomeHome DocumentationDocumentation

time-to-string

Converts a time to a string using the specified format.
Parameter
Type
Description
self
Time
The time to convert
format
String?
The format string. Supports HH, H, mm, m, ss, s. Use 'text' for literals. Optional, defaults to HH:mm:ss.
return
string
The formatted time string
Test Case:Convert time to string
    <div></div>
    
    <time-new hour="14" minute="30" second="45">
    <time-to-string>
    <assert-equal value="14:30:45" type="string">
    
    👆 Try to change something!
  • Test Case:Convert time with single digits
      <div></div>
      
      <time-new hour="9" minute="5" second="3">
      <time-to-string>
      <assert-equal value="09:05:03" type="string">
      
      👆 Try to change something!
    • Test Case:Format HH:mm
        <div></div>
        
        <time-new hour="14" minute="30" second="45">
        <time-to-string format="HH:mm">
        <assert-equal value="14:30" type="string">
        
        👆 Try to change something!
      • Test Case:Format without padding H:m:s
          <div></div>
          
          <time-new hour="9" minute="5" second="3">
          <time-to-string format="H:m:s">
          <assert-equal value="9:5:3" type="string">
          
          👆 Try to change something!
        • Test Case:Format mm:ss
            <div></div>
            
            <time-new hour="14" minute="30" second="45">
            <time-to-string format="mm:ss">
            <assert-equal value="30:45" type="string">
            
            👆 Try to change something!
          • Test Case:Format with literal string
              <div></div>
              
              <time-new hour="14" minute="30" second="45">
              <time-to-string format="H'h' m'min' s'sec'">
              <assert-equal value="14h 30min 45sec" type="string">
              
              👆 Try to change something!
            • Test succeeded Test failed