How to get actual date and time using c#

Posted by vsuri87-15045 under C# on 4/13/2012 | Points: 10 | Views : 7470 | Status : [Member] | Replies : 4
Hello,

I am using c#, Now I want to get the actual time, not form any services/network, i have these some webservices provided for thati dont want that.I want normal we have system.datetime.now means it's given what we are having in system time, but i change that system time, i want to get actual today's time.

Ex: my system time is :2012-04-13 today's date and it is normal method for

textbox.text= DateTime.Now; // it's gives 2012-04-13 , now i change my system time back/ forward that 2012-01-05 or 2012-10-06 like now i want to get that
textbox.text= here i want actual means today's date 2012-04-13

how we can get that time for this situation. Can you have any code for this

Please send that code

Thanks
Surendra




Responses

Posted by: Self-Innovator on: 4/13/2012 [Member] Bronze | Points: 25

Up
0
Down
try this...
SP
CREATE proc [dbo].[sp_GetCurrentDate]

as
declare @date varchar(10)
begin
set @date=(select CONVERT(varchar(10),getdate(),111))
select @date as CurrentDate
end

 protected void GetCurrentDate()

{
SqlConnection cnn = new SqlConnection(Conn);
SqlDataAdapter ada = new SqlDataAdapter("sp_getCurrentDate", cnn);
DataSet ds = new DataSet();
ada.Fill(ds);
lblDispDate.Text = ds.Tables[0].Rows[0]["CurrentDate"].ToString();
}


Join Hands Change lives
Thanks & Regards
Straight Edge Society

vsuri87-15045, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/13/2012 [Member] Silver | Points: 25

Up
0
Down
try this...

http://nickstips.wordpress.com/2010/02/12/c-get-nist-internet-time/

Regards,
Singaravel M

vsuri87-15045, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/13/2012 [Member] Silver | Points: 25

Up
0
Down
for universal time..

DateTime.Now.ToUniversalTime()
(or)
DateTime.UtcNow

Regards,
Singaravel M

vsuri87-15045, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vsuri87-15045 on: 4/13/2012 [Member] Starter | Points: 25

Up
0
Down
Not from any server/network/internet.

Previous one gives the server time.

vsuri87-15045, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response