Click here to Skip to main content
15,920,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends.... im working on a web application which will be used world wide ... mainly in saudi arabia and india. the timing of saudi arabia is 2:30 back compare to india. suppose any click found from india than india's datetime will be saved in database ... how we have to show it in saudi arabia. and have to convert database date corresponding to arabia datetime.


im serching on the internet ... but didnt find a proper solution till yet.... so please guide . how i can do this . thanks in advance .
Posted
Updated 17-Dec-15 19:14pm
v2

1 solution

C#
DateTime dt = new DateTime();
           dt = DateTime.Now;
           DateTime newdt = new DateTime();
           TimeSpan tim = new TimeSpan(-X, 0, 0, 0, 0);//hours Timespan(0,-X,0,0,0)
           newdt = dt.Add(tim);
           MessageBox.Show(newdt.ToString());



x = your number(+x means future date, -X means past datetime)
hope this help full.

Timespan(-x,0,0,0,0) will specify date and time of past
but just noew i read carefully your requirment hours right??
so just tri this Timespan(0,-X,0,0,0)
 
Share this answer
 
v3
Comments
Ashutosh shukla207 18-Dec-15 2:08am    
thanks a ton

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