#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    15
    Rep Power
    0

    date and time function in C


    hi!
    well i want to store date and time in my myql database...

    time(&now);
    nowbase = localtime(&now);

    if (nowbase)
    {
    hrtrans = nowbase->tm_hour;
    printf("Seconds for hours: %d\n", hrtrans);
    mintrans = nowbase->tm_min ;
    printf("Seconds for minutes: %d\n", mintrans);
    printf("SECONDS: %d\n", hrtrans + mintrans + nowbase->tm_sec);
    day = nowbase->tm_mday;
    printf("day of month: %d\n", day);
    month = nowbase->tm_mon; // Jan==0
    printf(" month of year: %d\n", month);
    year = nowbase->tm_year+1900;
    printf("year: %d\n",year);

    using this code i can get the values of..hour..minute,,day,,month and year..that is fine...but i also want to store the date in complete format..like 03.05.2003
    similarly time...10:30
    i cant fdigure out how can i store this in the required format in database...
    plz guide me
    waiting
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,251
    Rep Power
    2222
    I'm not sure what date format mySQL requires. There is a mySQL section on this forum, so you might want to post your question there as well.

IMN logo majestic logo threadwatch logo seochat tools logo