john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

time get

/* john pfeiffer 23jan08 program to get & manipulate time
 I want this format 01/08/2005 21:04 (dd/MM/YYYY HH:MM) so as to match the csv   */

#include<time.h>
#include<stdio.h>

int main(int argc, char* argv[])
{
    char temp[64];

    time_t timer;
    timer=time(NULL);   /*Calcs the current calender time and encodes it into time_t format. */

    printf("The default current time is %s.\n",asctime( localtime(&timer) ));

    strftime(temp, 63, "%d/%m/%Y %H:%M", localtime(&timer));
    printf("The formatted current time is %s.\n",temp);

    return 0;
}

/*
%a  abbreviated weekday name
%A  full weekday name
%b  abbreviated month name
%B  full month name
%c  appropriate date and time representation
%d  day of the month (01-31)
%H  hour of the day (00-23)
%I  hour of the day (01-12)
%j  day of the year (001-366)
%m  month of the year (01-12)
%M  minute of the hour (00-59)
%p  AM/PM designator
%S  second of the minute (00-61)
%U  week number of the year where Sunday is the first day of week 1 (00-53)
%w  weekday where Sunday is day 0 (0-6)
%W  week number of the year where Monday is the first day of week 1 (00-53)
%x  appropriate date representation
%X  appropriate time representation
%y  year without century (00-99)
%Y  year with century
%Z  time zone (possibly abbreviated) or no characters if time zone isunavailable
%%  %
*/

  • « file remove baddata v2
  • dos system »

Published

Jan 23, 2008

Category

c

~201 words

Tags

  • c 95
  • get 22
  • time 13