Firetron’s FormatDateTime

1 877 Views No Comments 3 years ago
  • Formats a unix datetime number (to “YYYY-MM-DD at HH:MM” by default).

    Custom Command Dependencies:
    None

    Test Script:

    if not Load('done', false) then
    
      local dateDelimiter
      local dateTimeDelimiter
      local timeDelimiter
      local includeSeconds
      local includeTime
      local includeYear
    
      local unix = Time()
    
      local formatted = CC_FormatDateTime(unix)
    
      Log(' ')
      Log(formatted)
      Log('Formatted Default:')
      Log(' ')
    
      includeSeconds = true
      local formatted1 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted1)
      Log('With Seconds:')
      Log(' ')
    
      includeTime = false
      local formatted2 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted2)
      Log('Without Time:')
      Log(' ')
    
      includeTime = true
      includeYear = false
      local formatted3 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted3)
      Log('Without Year:')
      Log(' ')
    
      dateDelimiter = '/'
      dateTimeDelimiter = ' - '
      timeDelimiter = '.'
      includeSeconds = true
      includeTime = true
      includeYear = true
      local formatted4 = CC_FormatDateTime(unix, dateDelimiter, dateTimeDelimiter, timeDelimiter, includeSeconds, includeTime, includeYear)
    
      Log(formatted4)
      Log('Formatted Another Way:')
      Log(' ')
    
      Save('done', true)
    
    end
    • This topic was modified 2 years, 2 months ago by Firetron. Reason: Removed tip addresses
    • This topic was modified 1 year, 10 months ago by Firetron. Reason: Added params to customize format. Added test script
    • This topic was modified 1 year, 10 months ago by Firetron. Reason: Changed test code
    • This topic was modified 1 year, 10 months ago by Firetron. Reason: Changed test code
    • This topic was modified 1 year, 10 months ago by Firetron. Reason: Changed a section header
    HaasScript Code
    Sign in or Register to download for free
  • Mandala Trading Competition Promotion Type: contest Expires: June 9, 2023 Exclusive
    Trading volume competition, win up to $10,000 USDT and bounties.
  • Earn Up to 200 BMEX Tokens Promotion Type: contest Expires: March 31, 2023
    15 BMEX @ $20,000, 25 BMEX @ $50,000, 50 [email protected] $200,000, 100 BMEX @ $400,000, 200 BMEX @ $600,000 in monthly derivatives volume
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free