Hels_UK
asked on
ASP.NET 2.0 - DateTime.Now How do I adjust to London time when host server is in California?
Hello,
I have the following code in my website:
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dateLabel.Text = DateTime.Now.ToString("ddd d, dd MMMM yyyy")
End Sub
</script>
Having recently transferred hosts to Lunarpages who are based in California (who are GMT/UTC - 08:00 hours), the date now displayed on my website is incorrect.
How do I adjust my code so the day changes at midnight UK time?
Many thanks
Karen
I have the following code in my website:
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dateLabel.Text = DateTime.Now.ToString("ddd
End Sub
</script>
Having recently transferred hosts to Lunarpages who are based in California (who are GMT/UTC - 08:00 hours), the date now displayed on my website is incorrect.
How do I adjust my code so the day changes at midnight UK time?
Many thanks
Karen
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or You can add hours or subtract hours of the difference between US time and UK time to ur textbox,
dim uktime as datetime
uktime = DateTime.Now
dim differenceHours as integer
'differenceHours = urdifference
uktime= uktime.AddHours(difference Hours)
dateLabel.Text = Convert.ToDateTime(uktime) .ToString( "dddd, dd MMMM yyyy")
Regards,
Mukesh
dim uktime as datetime
uktime = DateTime.Now
dim differenceHours as integer
'differenceHours = urdifference
uktime= uktime.AddHours(difference
dateLabel.Text = Convert.ToDateTime(uktime)
Regards,
Mukesh
ASKER
Hi,
Thanks for the response - I'm in the process of trying out the option from prajapati84 - I'll post my final answer here soon.
Hels
Thanks for the response - I'm in the process of trying out the option from prajapati84 - I'll post my final answer here soon.
Hels
Any reason why mine didn't work? It even used the same method calls.
adjustment = 0;
if (Running on Lunarpages) //Do a check to see if its http://yourwebsite.com or if its http://localhost for when your working @ home)
{
adjustment = X;
}
DateTime now = DateTime.Now;
now.AddHours(adjustment);