title: C - How to convert time_t to tm?
body: <p>I have a variable which using <code>time_t</code> data type. I want to convert this type into "YYYY-MM-DD HH:MM:SS". I just know if it's only works in <code>localtime()</code> example:</p>
  
  <pre><code>char buff[20];
  time_t now = time(NULL);
  strftime(buff, 20, "%Y-%m-%d %H:%M:%S", localtime(&amp;now));
  </code></pre>
  
  <p>any suggestion how to convert it? because I have the time which always increased every minute, not the fixed one like the <code>localtime()</code>. I need this conversion for matching with <code>datetime</code> type in MySQL database.</p>