473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Current Time in C#

Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks

--
-iwdu15
Nov 24 '06 #1
4 92902
On Thu, 23 Nov 2006 18:25:01 -0800, iwdu15 wrote:
Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks
DateTime current = DateTime.Now;
--
Tom Porterfield
Nov 24 '06 #2
haha wow im oblivious, thanks a lot
--
-iwdu15
Nov 24 '06 #3
Hi
DateTime is a class in System namespace. As Base class library is
shared across the platform, C# can happily use DateTime

You can use the same class DateTime in C# also.

DateTime current = DateTime.Now; will give you the current date time
:-)

Thanks
-Srinivas.


Tom Porterfield wrote:
On Thu, 23 Nov 2006 18:25:01 -0800, iwdu15 wrote:
Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks

DateTime current = DateTime.Now;
--
Tom Porterfield
Nov 24 '06 #4
iwdu15,

"Now" is a method in the standard Net namespace Microsoft.VisualBasic, you
can use it in C# in the same way as every other standard Net namespace.

In VB you can use in two ways the "using" declaration of namespaces. One is
in the project properties and one is in the same way although you use
"Import" in the same way as in C#. In VB.Net are in the same way as in C#
automaticly set some namespaces to use when you open things like a form.
Including in that is forever the namespace VisualBasic, however you don't
see it, it is in the Project Propertys.

For the rest C# and VB.Net are here again exactly the same.

(I would never use this namespace in C# only to get the Now method by the
way).

I hope this explains it a little bit.

Cor

"iwdu15" <jmmgoalsteratyahoodotcomschreef in bericht
news:47**********************************@microsof t.com...
Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks

--
-iwdu15

Nov 24 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Chris | last post by:
Sorry, This should be simple, but brain is hurting... How do I convert a Current Time to a Decimal 6,0 (HMS)? There must be a cleaner way then this: Insert into Table Values Dec(...
2
by: MarthaR | last post by:
I am trying to add the current time to a field when the user clicks on the toggle button next to the field. I am getting a time of 12:00:00 AM each time I click the button. How do I get a...
18
by: Tim Quon | last post by:
Hi I need to print the current time. I found an example where this is done as followed: long *mytime; time(mytime); printf("time: %s", ascitime(mytime); But this doesn't work and prints...
3
by: | last post by:
I have a datetime field in table. I want to insert the current time of database server to the table thr ASP.NET (C#). I have dataset to do the insert: DataSet1.TableNameRow rowNew =...
4
by: Gary Wessle | last post by:
Hi I am not getting current time with this program, what am I doing wrong? #include <ctime> #include <iostream> using namespace std; #define P(x) cout << #x " = " << (x) << "\n";
0
by: Saloni | last post by:
I have windows service which is going to run on several machines which are in different time zones in USA. I want to find out the Eastern Zone current time from these different machines. It...
3
by: Mark Ingram | last post by:
Hi, I'd like to know the best way of checking the current time during a demonstration product. At the minute i store the first run date, then compare that to the system time, but obviously a user...
4
by: JuAn2226 | last post by:
Hi, can anyone help me . when my program starts there is numbers and time will be display in the form of visual basic. it will run continuesly .My problem here is i dont know how to display the data...
1
oranoos3000
by: oranoos3000 | last post by:
hi I want to get current time from server only once while user open page from site and repace this time with current time client and with each second that is added this time is added how can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.