Server Date & Time vs. Local Date & Time

I have the following code (which some members assisted with) and it works great locally...

It takes the date and time and formats just the way I want:  e.g.:  10/28/2008 13:58:44 becomes 102820080158 (which is what I want)

But, when I upload the app to our server the date pulled is:           10/28/2008 1:59:37 PM

As a result the date skips the formatting and does not work, so how can I code this so the date/time will be the same whether its local or on a server, and I have adjusted the regional settings to match - and same issue...

string Input = Convert.ToString(DateTime.Now);
        DateTime Output;

        if (DateTime.TryParseExact(Input,
            "MM/dd/yyyy H:mm:ss",
            CultureInfo.InvariantCulture,
            DateTimeStyles.AllowWhiteSpaces,
            out Output))
        {
            Input = Output.ToString("MMddyyyyhhmm");
        }

        txtUniqueOrder.Text = Convert.ToString(currentuser) + Input;

0
jaymdouglas
10/28/2008 6:00:22 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

1 Replies
771 Views

Similar Articles

[PageSpeed] 23

Your server is configured for en-US, your local machine is not... possibly en-CA or something similar. Instead of doing Convert.ToString(DateTime.now), you should try something invariant, like you do in the later part of your code.

Let say:

string Input = DateTime.Now.ToString(CultureInfo.InvariantCulture);

Then you will be staying consistant with both section of your code. I'm not sure if InvariantCulture's default is the correct one, so you may need to also add a format string to that code as the first (I think) parameter, but I think you will know what to do then :)

 

0
shados
10/28/2008 6:33:24 PM
Reply:

Similar Artilces:

Get Date & Time from server
Hi Everybody, I'm developping with PB8 & ASA7. How can I get the current Date & Time from ASA on the server. Thank you. Allo. <ALLO> wrote in message news:40ec5282.4d5f.1681692777@sybase.com... > Hi Everybody, > > I'm developping with PB8 & ASA7. How can I get the current > Date & Time from ASA on the server. > > Thank you. > > Allo. Try this: CREATE PROCEDURE ap_SysTime @a_systime datetime OUTPUT AS SET NOCOUNT ON select @a_systime = GETDATE() SET NOCOUNT OFF go Steve SELECT CURRENT TIMEST...

date/time or date and time
I am setting up an SQL database and I will need to get differences in dates. For example I have a start date, start time, completion date and completion time and I want to get the difference between the start and completion. Would it be better to have one field with both date and time in it, or better to have a date field and a time field? Even though I have already started setting up the tables with seperate fields for date and time I am now leaning toward one field with date/time in it. (Only because that is the way I had to do it when setting up an Excel spreadsheet for a similar ta...

Date & Time from Server
How do I retrieve the date & time from my server? It is in another time zone from my workstations. Want to store the server time, not the workstation time There's a command-line ... er... command you could use. NET TIME //computername <Anonymous@sybase.com> wrote in message news:DE22AF161A5E54DC0079854985256988.0079855985256988@webforums... &gt; How do I retrieve the date &amp; time from my server?&nbsp; It is in another time <BR> &gt; zone from my workstations.&nbsp; Want to store the server time, not the <BR> &gt; workstation...

Server Date & time
Could you please let me know how to retrieve the Server Date and time How to to retrieve HOUR of the Server's date and time Thanks Dim d1 As DateTime = DateTime.Now 'This is what you want dim myHour as Integer = d1.HourDarrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! Sorry Datetime.now will give the time of the local system not Server The following will show you the hour of the server's date and time.<%@ Page Language="VB" %> <script runat="server"> Sub Page_Load( sender As Object, e...

Speeding up date time & time zone code
From profiling, I think the single biggest speed up that could be done for DateTime, when using an Olson DB timezone, would be to implement Tree::RedBlack in XS. Even better would be to implement a custom red-black tree that natively worked with the kind of weird values that are fed into (complex data structures as opposed to scalars). This would be a huge win for anyone who had to work with time zones. Any takers? -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/ >Even better would be to implement a custom &g...

File time & date change every time
Hi, Since some days, I have a curious problem with file time/date on my file server Novell 6.5 (service pack 4). The date/time "last modified" always change. For example, I have a file "last modified" 12 september 2003, 17:40. Each time I verify the Properties with Windows XP pro, this time/date increase !!!. If I copy this file on a local harddisk, the date is fixed on the file copied, but continue to increase on my file server. It create hudge problems for incremental backup !!! Any idea to resolve this strange situation ??? Thanks in advance ! ea...

Load Server Date&Time
 I am Working in Asp.net C#.I want to load Server Date and Time(Not Local) into a Label Control. sajith lblWhatever.Text = Now.ToString(); Hi, DateTime.Now.ToString() will return as current date and time on server. You can also just get date or time via string format. DateTime.Now.ToString("MM/dd/yyyy") will return current date. DateTime.Now.ToString("hh:mm:ss") will return as current time. You can get more information about it by using the following link: http://msdn2.microsoft.com/en-us/library/system.datetime.now.aspx Hope it helps.Vince XuMicrosoft...

How to change the calendar control date & year & time
Hi, I wonder how to change calendar date / year time. Because I type Calendar1.VisibleDate.Subtract(TimeSpan.FromDays(365)); to show the calendar one year ago but it just does not show the correct year. In fact it seems that nothing happend when I trigger that event using a button Because what I want to do is to display a calendar and on top of it I wanna display a combo box so that the user can just use the combo box to navigate to the desired year. I don't think using previous month and next month as provided in the calendar would be efficient. Hope someone can help m...

date & time from server problem/question
Hi all, I'm trying to get the date & time a file was created on the server, I RTFM and I found: 10 ctime inode change time (NOT creation time!) in seconds since the epoch http://www.xav.com/perl/lib/Pod/perlfunc.html#item_stat How can I get the date & time of files from the server? Cheers, G :) Public Sub House() On Error Resume drink If Pint.empty = True Then Pint.refill Else Pint.drink End if stomach.add Pint MsgBox " I've had .... " & stomach.count &...

Free Online Dating For You - Love & Dating
Hi Must visit these sites! http://free-online-dating-for-you.blogspot.com/2010/05/how-to-ask-someone-out-on-date.html http://free-online-dating-for-you.blogspot.com/2010/05/3-things-youll-hardly-consider-as.html http://free-online-dating-for-you.blogspot.com/2010/05/fool-proof-ways-to-pick-up-girls.html http://free-online-dating-for-you.blogspot.com/2010/05/what-you-need-to-know-how-to-seduce.html http://free-online-dating-for-you.blogspot.com/2010/05/some-easy-steps-on-how-to-get-women.html http://free-online-dating-for-you.blogspot.com/2010/05/about-dating.html http://free-online-da...

java date time and utc date time
hi i have a client written in delphi the backend is written in java (webservice) when fetching a date field from the db, through java to delphi (TXSDateTime class), for some reason the date changes. in the db: 30/07/2009 00:00:00 in delphi: xsdatetime.asdatetime = 29/07/2009 23:00:00 (1 hour before) in delphi xsdatetime.asutcdatetime = 29/07/2009 21:00:00 (3 hours before) i guess it's a matter of timezones but all we want is simply to fetch the same date as it appears in the DB what are we missing? thanks amos szust wrote: > hi > > i have a client written in d...

Novell 4.91 sp2 & 3 date & time error
All, We're having an issue on *some* machines w/ an older version of the Novell client where it resets the year / time all wacky. All these machines have the exact same date & time (year 2146). All of them have either been SP2 or SP3 of the client & are setting the date & time through the client. Is there any cause for this? Our sys admins have reported all servers are sync'd w/ the correct date & time. Here's another person having the exact same problem, except last year: 'XP Windows time and date problem - Windows XP Support' (http:/...

Date & Time
Hi all, How can I display the date and time on the page. I tried to display them by using VB code, but it resulted nothing. The code is: Protected Sub lbldateTime_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbldateTime.Load Dim dtNow As DateTime = DateTime.Now End Sub =============== I donno which declaration should I use. I used the "Load", but nothing happened. Could anyone help!? drag a Label control onto your page where you want the datetime to appear then put this code into your page_load'assuming the lable has an id of Label1 Label1.Text = DateTime.Now...

Date & Time
If you know any place where they explain about formating date and time with example please let me know Thanks Check below link, it coul throw some light for your question http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemGlobalizationDateTimeFormatInfoClassTopic.asp Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti...

Web resources about - Server Date & Time vs. Local Date & Time - asp.net.getting-started

Server farm - Wikipedia, the free encyclopedia
A server farm or server cluster is a collection of computer servers usually maintained by an enterprise to accomplish server needs far beyond ...

Price Drop: MyAudioStream Pro UPnP audio player and streamer: gather your music collection from your ...
MyAudioStream Pro UPnP audio player and streamer: gather your music collection from your PC, NAS, UPnP servers, Windows Media Player or iTunes ...

Intel Rising: Server Stronger Than Ever, Says JMP; Here Comes Apple?
... stock to Market Outperform from Market Perform, assigning a $45 price target, righting that the company will strengthen its hold on its server ...

Samsung's first 128 GB DDR4 RAM modules for servers go into production
... mass production of the industry’s first "through silicon via" (TSV) 128GB DDR4 memory modules for high-end enterprise and data centre servers. ...

Latest Windows Server 2016 beta shows off Microsoft's new containers
Microsoft launched the fourth technical preview for the next version of Windows Server on Thursday, giving the public access to its new Hyper-V ...

Senator Wonders If Hillary Is Covering Legal Expenses For Tech Firm That Managed Her Email Server
Senator Wonders If Hillary Is Covering Legal Expenses For Tech Firm That Managed Her Email Server

Quanta, Wiwynn see more orders from server clients for 2016
Quanta Computer and Wiwynn, a server subsidiary of Wistron, are expected to land more cloud server orders from their clients in 2016 as Internet ...

Sadelle's Is So Hot That the Servers Are Literally Catching on Fire
Actual flames. Sadelle's, the wildly popular Soho Jewish bakery/bistro from Major Food Group, launched dinner last week with a menu that includes ...

Microsoft Previews Hyper-V Containers for Windows Server 2016
Wondering how Hyper-V containers work in Microsoft's upcoming server software release? Intrepid administrators and developers can get an early ...

Many Android apps talk to private servers — and it’s often not clear why
A new report finds that a significant percentage of Android applications engage in covert communication but it's not always clear who they are ...

Resources last updated: 11/28/2015 11:25:05 AM