This blog is under construction

Saturday 5 May 2012

localtime example in C

Header file:
    time.h

Synopsis:
     struct tm *localtime(const time_t *t1);

Description:
     It converts calendar time t1 to local time(broken time - returns structure tm).


localtime function C example:


  #include<stdio.h>
  #include<time.h>
  int main() {
        time_t tp;
        struct tm *ts;
        char *str;
        tp = time(NULL);
        ts = localtime(&tp);
        str = asctime(ts);
        printf("%s", str);
        return 0;
  }




  Output:
  jp@jp-VirtualBox:~/cpgms/time$ ./a.out
  Sat May  5 23:55:17 2012



1 comment:

  1. Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks

    ReplyDelete