473,218 Members | 1,459 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,218 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 92885
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

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.