title: Powershell Current time minus n seconds in specific format
body: <p>I am looking to store value of <strong>current system time - 30 seconds in the format [yy.mm.dd hh:mm:ss] in a variable.</strong>
  This is a specific requirement as the log file i am working on has this format. Currently i have below code which allows me to store current system time in required format but unable to subtract 30 seconds.</p>
  
  <pre><code>$dateTime = Get-Date -f "[yy.MM.dd HH:mm:ss]"
  $("Current time: " + $dateTime)
  $("Current time - 30 second: " + $dateTime.AddSeconds(-31))
  </code></pre>
  
  <p>The line <code>$("Current time - 30 second: " + $dateTime.AddSeconds(-31))</code> from above code throws below error</p>
  
  <pre><code>Method invocation failed because [System.String] does not contain a method named 'AddMinutes'.
  At C:\Users\foo\log_mont.ps1:4 char:3
  + $("Current time - 30 second: " + $dateTime.AddSeconds(-31))
  +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : MethodNotFound
  </code></pre>