Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 13th, 2011, 08:15 AM
Friend of Wrox
 
Join Date: Apr 2010
Posts: 125
Thanks: 20
Thanked 3 Times in 3 Posts
Default Server and Client Time difference

Hi there,
When You run DateTime.Now.ToString() in your PC browser, it shows the correct time. However, When You run it on Server the time is not correct(But date is correct). Because in last case you receive server(maybe in another country ) time but in first case you receive You PC time. How we can calculate the difference time between server and client?
__________________
Please excuse me for poor and bad English.
 
Old September 13th, 2011, 02:38 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
When You run it on Server the time is not correct(But date is correct).
The date could be "wrong" as well as the day has already changed in one timezone but not yet in the other.

But it all depends on what you mean with "correct" and "wrong". If I as a visitor were in the same time zone as the server it could be right for me....

You can take a look at ToUniversalTime on the DateTime struct (http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx) which gives the universal time regardless the timezone. Then you can calculate back to the user's time zone if you have that information (could base it on an IP address, or ask the user's timezone as these Wrox forums do it).

For future questions like these that are not directly related to my book, would you mind posting in a more general ASP.NET category from this list:http://p2p.wrox.com/asp-net-4-539/

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 13th, 2011, 02:43 PM
Friend of Wrox
 
Join Date: Apr 2010
Posts: 125
Thanks: 20
Thanked 3 Times in 3 Posts
Default

Quote:
For future questions like these that are not directly related to my book, would you mind posting in a more general ASP.NET category
I am sorry, in future post i care about it.
Thanks for your help. It help me.
__________________
Please excuse me for poor and bad English.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating a time difference SQLScott SQL Server 2005 11 October 25th, 2007 02:42 AM
difference in time MunishBhatia ASP.NET 2.0 Professional 0 September 5th, 2007 09:03 AM
Difference between client edition and server editi pybrajesh SQL Server 2005 1 October 5th, 2006 10:34 PM
DLLs on server pulling server time or client? mussitsch Classic ASP Professional 1 March 1st, 2005 05:38 AM
Time difference spraveens PHP How-To 4 September 20th, 2004 07:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.