how to get current time

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

Page 1 of 1

8 Replies - 25652 Views - Last Post: 03 July 2008 - 04:19 AM Rate Topic: -----

#1 azeeejaz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-July 08

how to get current time

Post icon  Posted 02 July 2008 - 12:03 AM

hi i want to get current time and date in integer values plz help me
fnx alot
Is This A Good Question/Topic? 0
  • +

Replies To: how to get current time

#2 3DrunkPandas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 06-October 07

Re: how to get current time

Posted 02 July 2008 - 05:46 AM

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

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

Was This Post Helpful? 0
  • +
  • -

#3 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: how to get current time

Posted 02 July 2008 - 05:51 AM

View Post3DrunkPandas, on 2 Jul, 2008 - 05:46 AM, said:

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

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:

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


This post has been edited by eclipsed4utoo: 02 July 2008 - 05:52 AM

Was This Post Helpful? 0
  • +
  • -

#4 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: how to get current time

Posted 02 July 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.
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: how to get current time

Posted 02 July 2008 - 06:16 AM

View Postzakary, on 2 Jul, 2008 - 05:56 AM, said:

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.
Was This Post Helpful? 0
  • +
  • -

#6 3DrunkPandas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 06-October 07

Re: how to get current time

Posted 02 July 2008 - 11:58 AM

View Posteclipsed4utoo, on 2 Jul, 2008 - 06:16 AM, said:

View Postzakary, on 2 Jul, 2008 - 05:56 AM, said:

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.
Was This Post Helpful? 0
  • +
  • -

#7 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: how to get current time

Posted 02 July 2008 - 12:02 PM

View Post3DrunkPandas, on 2 Jul, 2008 - 11:58 AM, said:

View Posteclipsed4utoo, on 2 Jul, 2008 - 06:16 AM, said:

View Postzakary, on 2 Jul, 2008 - 05:56 AM, said:

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.
Was This Post Helpful? 0
  • +
  • -

#8 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to get current time

Posted 02 July 2008 - 12:06 PM

Come on now guys, he was merely trying to help, and last time I checked thats what we were here for :) I've inadvertently posted code that had an error (or 2 lol) in it, it happens.
Was This Post Helpful? 0
  • +
  • -

#9 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: how to get current time

Posted 03 July 2008 - 04:19 AM

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: 03 July 2008 - 04:24 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1