Skip to content

Instantly share code, notes, and snippets.

@0xABD 0xABD/timestamp.c
Created Sep 7, 2015

Embed
What would you like to do?
print local timestamp as YYYYMMDDHHMISS
#include <stdio.h>
#include <time.h>
/*
@ECHO OFF
for /f %%a in ('timestamp.exe') do (set ts=%%a)
echo %ts%
*/
int main(int argc, char **argv)
{
time_t ltime;
struct tm *_tm;
ltime = time( NULL );
_tm = localtime( &ltime );
printf( "%04d%02d%02d%02d%02d%02d",
_tm->tm_year + 1900,
_tm->tm_mon + 1,
_tm->tm_mday,
_tm->tm_hour,
_tm->tm_min,
_tm->tm_sec );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.