Firetron’s FormatDateTime

1 1157 Views No Comments 4 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
    HaasScript Code
    Sign in or Register to download for free
  • Earn Up to $100,000 USDT Promotion Type: contest Expires: June 30, 2024 Exclusive
    Fire up your trade bots and earn up to $100,000 USDT, BitMEX VIP, free subscriptions, and more.
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free