SunQuest
           C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old May 3rd, 2003, 06:51 AM
aleezah aleezah is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 15 aleezah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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

Reply With Quote
  #2  
Old May 3rd, 2003, 04:17 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,803 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 11 h 55 m 53 sec
Reputation Power: 437
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > date and time function in C


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway