Thread: Time problem

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    22

    Time problem

    Well i'm doing a program to managem incoming and outcoming payments, but i need to get the date from de system of the client pc, but i dunno any functions about time, i looked and i've found nothing, so help me i need a function that return time in some like stamp: 01/11/1991.

    thx

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Check out strftime()
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    well, right now i discovery the answer to my question, this strftime is good for me, but this code right down here is better take a look. thx by the help
    Code:
    int dia, mes, ano;
    struct tm *local;
    time_t t;
    t= time(NULL);
    local=localtime(&t);
    dia=local->tm_mday;
    mes=local->tm_mon+1;
    ano=local->tm_year+1900;
    printf("Data do Sistema: %d/%d/%d\n",dia,mes,ano); // Retorna a data

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    No problem. If you want to make sure your months and days are always 2 digits then change from:
    Code:
    %d/%d/%d
    to:
    Code:
    %02d/%02d/%04d
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer problem... i think
    By fatdunky in forum C Programming
    Replies: 6
    Last Post: 11-30-2005, 03:45 PM
  2. another problem with catstr() this time
    By the_winky_files in forum C Programming
    Replies: 19
    Last Post: 09-22-2005, 04:20 PM
  3. time problem
    By sand_man in forum C Programming
    Replies: 9
    Last Post: 09-13-2005, 05:59 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. Problem with time on the board, or is it just me?
    By biosninja in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 10-23-2002, 05:45 AM