Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Frnds,

i need a Message 5 min back compare to system date.

Suppose now the time is 11:50 am.. I need the message as Last updated at 21/04/2012 11:45 am.

this message should be 5 min less than system time.

Thanks,

This is my code.



SQL
//protected void UpdateTimer_Tick(object sender, EventArgs e)
    //{
    //    Label3.Text = "Last Updated at : " + DateTime.Now.ToLongTimeString();
    //}
Posted

Just Use this code..

protected void UpdateTimer_Tick(object sender, EventArgs e)
{
    Label3.Text = "Last Updated at : " 
         + DateTime.Now.AddMinutes(-5).ToLongTimeString();
}
 
Share this answer
 
Use this

DateTime.Now.AddMinutes(-5);
See this
http://wiki.lessthandot.com/index.php/ASP.NET:_Simple_date_and_time_methods[^]
 
Share this answer
 
DateTime's AddMinutes method Adds the No. of minutes specified in parameter. If it's a Negative Number then it subtracts that No. of minutes.

So,
DateTime.Now.AddMinutes(-5) will serve the purpose.

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900