Link to home
Start Free TrialLog in
Avatar of Hels_UK
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("dddd, 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
Avatar of UnexplainedWays
UnexplainedWays


            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);

ASKER CERTIFIED SOLUTION
Avatar of UnexplainedWays
UnexplainedWays

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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(differenceHours)
dateLabel.Text = Convert.ToDateTime(uktime).ToString("dddd, dd MMMM yyyy")

Regards,
Mukesh
Avatar of Hels_UK

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
Any reason why mine didn't work?  It even used the same method calls.