[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ASP.NET 2.0 - DateTime.Now How do I adjust to London time when host server is in California?

Posted on 2006-11-12
9
Medium Priority
?
363 Views
Last Modified: 2017-08-30
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
0
Comment
Question by:Hels_UK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
9 Comments
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 17927768

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

0
 
LVL 12

Accepted Solution

by:
UnexplainedWays earned 252 total points
ID: 17927774
You'll need to find out the time currently and what the time of the server is, and then do the math and replace the X with the number.

Check out http://msdn2.microsoft.com/en-us/library/system.datetime_members.aspx

----
AddDays         Adds the specified number of days to the value of this instance.
AddHours       Adds the specified number of hours to the value of this instance.
AddMilliseconds       Adds the specified number of milliseconds to the value of this instance.
AddMinutes       Adds the specified number of minutes to the value of this instance.
AddMonths       Adds the specified number of months to the value of this instance.
AddSeconds       Adds the specified number of seconds to the value of this instance.
AddTicks       Adds the specified number of ticks to the value of this instance.
AddYears       Adds the specified number of years to the value of this instance.
----
0
 
LVL 5

Assisted Solution

by:prajapati84
prajapati84 earned 248 total points
ID: 17928737
Try this one...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     Dim culture As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-GB")
     dateLabel.Text = DateTime.Parse(DateTime.Now.ToString("dddd, dd MMMM yyyy"), culture, System.Globalization.DateTimeStyles.NoCurrentDateDefault)
End Sub

Regards,
Mukesh
0
Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

 
LVL 5

Expert Comment

by:prajapati84
ID: 17928842
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
0
 

Author Comment

by:Hels_UK
ID: 18020894
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
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 18189820
Any reason why mine didn't work?  It even used the same method calls.
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question