Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 117,618 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 1,942 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



how to get current time

 
Reply to this topicStart new topic

how to get current time, how to get current time and get d values hh/mm/ss in different intege

azeeejaz
post 2 Jul, 2008 - 12:03 AM
Post #1


New D.I.C Head

*
Joined: 2 Jul, 2008
Posts: 1


hi i want to get current time and date in integer values plz help me
fnx alot
User is offlineProfile CardPM

Go to the top of the page


3DrunkPandas
post 2 Jul, 2008 - 05:46 AM
Post #2


New D.I.C Head

*
Joined: 6 Oct, 2007
Posts: 22


My Contributions


I think you have to create a new DateTime object and get its Now field.

CODE
DateTime myTime = new DateTime();
int hh = myTime.Now.hh;
int mm = myTime.Now.mm;
int ss = myTime.Now.ss;
User is offlineProfile CardPM

Go to the top of the page

eclipsed4utoo
post 2 Jul, 2008 - 05:51 AM
Post #3


D.I.C Head

**
Joined: 21 Mar, 2008
Posts: 155



Thanked 7 times
My Contributions


QUOTE(3DrunkPandas @ 2 Jul, 2008 - 05:46 AM) *

I think you have to create a new DateTime object and get its Now field.

CODE
DateTime myTime = new DateTime();
int hh = myTime.Now.hh;
int mm = myTime.Now.mm;
int ss = myTime.Now.ss;



do people even try the code out before writing it? that code has 6 errors.

here is the correct code:

C#

int hours = DateTime.Now.Hour;
int minutes = DateTime.Now.Minute;
int seconds = DateTime.Now.Second;


This post has been edited by eclipsed4utoo: 2 Jul, 2008 - 05:52 AM
User is offlineProfile CardPM

Go to the top of the page

zakary
post 2 Jul, 2008 - 05:56 AM
Post #4


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 382



Thanked 4 times

Dream Kudos: 175
My Contributions


Maybe 3DrunkPandas forgot that there is no hh in DataTime that hh is used when converting DateTime to string and hh is a string format.
User is offlineProfile CardPM

Go to the top of the page

eclipsed4utoo
post 2 Jul, 2008 - 06:16 AM
Post #5


D.I.C Head

**
Joined: 21 Mar, 2008
Posts: 155



Thanked 7 times
My Contributions


QUOTE(zakary @ 2 Jul, 2008 - 05:56 AM) *

Maybe 3DrunkPandas forgot that there is no hh in DataTime that hh is used when converting DateTime to string and hh is a string format.


he also forgot that the ".Now" property of the DateTime class is not accessible from an instance of the DateTime class.
User is offlineProfile CardPM

Go to the top of the page

3DrunkPandas
post 2 Jul, 2008 - 11:58 AM
Post #6


New D.I.C Head

*
Joined: 6 Oct, 2007
Posts: 22


My Contributions


QUOTE(eclipsed4utoo @ 2 Jul, 2008 - 06:16 AM) *

QUOTE(zakary @ 2 Jul, 2008 - 05:56 AM) *

Maybe 3DrunkPandas forgot that there is no hh in DataTime that hh is used when converting DateTime to string and hh is a string format.


he also forgot that the ".Now" property of the DateTime class is not accessible from an instance of the DateTime class.


Eh sry... I'm currently learning the language, so I'm far from being a professional.
User is offlineProfile CardPM

Go to the top of the page

eclipsed4utoo
post 2 Jul, 2008 - 12:02 PM
Post #7


D.I.C Head

**
Joined: 21 Mar, 2008
Posts: 155



Thanked 7 times
My Contributions


QUOTE(3DrunkPandas @ 2 Jul, 2008 - 11:58 AM) *

QUOTE(eclipsed4utoo @ 2 Jul, 2008 - 06:16 AM) *

QUOTE(zakary @ 2 Jul, 2008 - 05:56 AM) *

Maybe 3DrunkPandas forgot that there is no hh in DataTime that hh is used when converting DateTime to string and hh is a string format.


he also forgot that the ".Now" property of the DateTime class is not accessible from an instance of the DateTime class.


Eh sry... I'm currently learning the language, so I'm far from being a professional.


We are here to help others so it's always good to post code that is correct. With you being new to the language(I am also, only about a year and a half under my belt), always do the code in VS before posting it here. Make sure that it does exactly what it should and make sure there are no errors.
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 2 Jul, 2008 - 12:06 PM
Post #8


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,831



Thanked 80 times

Dream Kudos: 8050

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI, Boo.Net

My Contributions


Come on now guys, he was merely trying to help, and last time I checked thats what we were here for smile.gif I've inadvertently posted code that had an error (or 2 lol) in it, it happens.
User is offlineProfile CardPM

Go to the top of the page

zakary
post 3 Jul, 2008 - 04:19 AM
Post #9


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 382



Thanked 4 times

Dream Kudos: 175
My Contributions


Oh I know that is why I posted what I did I was not putting him down I was just stating that he may have forgotten I have done that myself once or twice, and I apologies if I offended you 3DrunkPandas, that is not what I was trying to do.

This post has been edited by zakary: 3 Jul, 2008 - 04:24 AM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/8/08 12:04AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month