Display The ServerTime In Four Different Time Zones With JScript?
Nov 28, 2010
I am adding a custom header to a SharePoint master page and I would like to display the current time in four different time zones. However, I don't want to use the client's time as there is no way to know what time zone the client will be in, or if they have the correct time on their computer.
My problem is that I really don't know anything about ASP.NET, as I'm a PHP guy myself. So I need a way to pass the serverTime as a variable that JavaScript can use to perform calculations on to display the correct time zone.
UPDATE:
I need the clock to update as each second changes. So it is a live time instead of a static time.
UPDATE 2:
This is the code I'm using.
<script runat="server">
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
End Sub
Public Function dtBase() As Double
Dim d1 As Date = New Date(1970, 1, 1)
[Code]....
UPDATE 3:
Still don't know if the code worked. My SharePoint server rejected the page for the code blocks. I have absolutely zero idea how to do code-behind. The JS works, but if the client's time is off, the site displays incorrect times. Really wish I could just code this in PHP. I'd be done a week ago. ;)
UPDATE 4:
This update is for anyone that stumbles across this in the future looking for the answer to the problem. The code above has been updated to work correctly. The only catch is that SharePoint disallows code by default, so to enable it, you have to modify the web.config file. The web.config file is usually in the root directory of the site. Inside that file (which is XML), you'll find a tag. Somehwere inside of that, you should find , and inside of that, you should find . Inside of that tag, you want to add this:
I'm having an issue working out how to implement this time based event. Basically, my program needs to send out an email at 12AM monday morning. But the email needs to go based on the user's local time not 12AM server time.
the problem i have discovered is Daylight savings. I used current server time as 12:00AM (my local time) and my actual offset is -7:00 UTC but after the calculation i get -6:00 utc because of daylight savings. If a user was in -7:00UTC then he/she will not get the email at 12am localtime but an hour late.
I got this answer from Kjensen and read the answers, but this is a different webapp
I'm running scheduled events that process incoming orders, set Picking material, manage Track & Trace numbers, etc ... and I do this at a specific time of the day (set in Administration Panel)
My server is in UK (DiscountAsp.net) but I'm 2 hours ahead.
What I really wanted is, every time I call DateTime.Now that would be automatically changed to my time instead of Local Server Time. This should handle Daylight savings as well.
I thought about making a Extension to simply call DateTime.MyLocalTime and there use TimeInfo to add / subtract the correct hours.
In good old days I did this in Global.asa (ASP) ... I just wanted to know if there is a better way to handle this.
Find if the current time falls within hourly ranges and display the start hour and end hour of that range in labels.
Examples:
If the current time is 8:46am, label startTime would return "8am" and label endTime would return "9am" If the current time is 10:01pm, label startTime returns "10pm" and label endTime returns "11pm" If the current time is 12:59am, label startTime returns "12am" and label endTime returns "1am"
I have been working with the C# TimeRange class but not getting what I need.
We have a generic site which we deploy to clients and they personalise the text using the web parts. The problem we are currently experiencing is that they are unable to move web-parts between zones. This is not a JS issue as no errors are being thrown and this is not a CSS issue either, as we re-deployed the website here on our own server and it works perfectly fine. On our client's site, we can drag parts around in the zone it is in, however when we try to move a part out of that zone, we are given a circle cursor with a line through it. Adding parts to a zone is not an issue.
This could perhaps be linked to a previous issue of being unable to view any editable parts of a webpart. I resolved this by removing all the WebPersonalization from the WebPersonalization table in our MSSQL database.
I would like to achieve a nice smooth transition when the user moves controls between the WebPartZones similar to how iGoogle implements it. I've not yet been able to achieve this - the transition is very jumpy and not very smooth (I cannot use SilverLight).
Has anybody achieved this using WepPartZones without the use of SilverLight?
I have a WebPartZone in each of two adjacent columns. There is a gap of about 4 pixels between the two columns that I cannot remove.
I have two zones with the following markup:
[Code]....
On running the page, the relevant source code is:
<%-- End of contents and div containers for Column 1 Zone --%> ...jText at the end of this Webpart.</span> </td></tr></tbody></table> </td></tr></table> </td></tr> <tr>td style="padding:0;height:100%;"></td> </tr></table> </td></tr></table> </div> </div> <%-- Start of div containers for Column 2 Zone --%> <div id="ctl00_Main_MainCol2" class="box33" style="Width:39.9%;"> <div id="ctl00_Main_MainCol2Con" style="width:auto; margin-left:0.0em; margin-right:0.0em;"> <table cellspacing="0" cellpadding="0" border="0" id="ctl00_Main_ZoneCol2"> <tr><td style="height:100%;"> <%-- The following 2 tables both have cellpadding="2" which appears to be causing the problem --%> <table cellspacing="0" cellpadding="2" border="0" style="width:100%;height:100%;"> <tr><td> <table cellspacing="0" cellpadding="2" border="0" id="WebPart_wp1787670866" style="width:100%;"> <tr><td cellpadding="0" style="padding:0px;"> <div id="ctl00_Header_WebPartManager1_wp1787670866"></div> <%-- Start of contents of Column 2 Zone --%> <table cellspacing="0" cellpadding="10" style="border: thin solid #000000; background-color: #8db3e2; width: 100%;"> <thead> </thead> <tbody> <tr> <td><span style="font-size: 12px;">Text at the beginning of this WebPart....
Two of the tables, which I think are rendered by the WebPartZones, have cellpadding="2". This seems to be giving the 4 pixel gap between the columns.
need to insert huge data into a local SQL server table from remote SQL server every day.I need to create a project to display how many minutes left while inserting based on table size and network speed.Can someone give an idea of how to do it?
I am developing an application using Asp.Net.My question is whether there is any solution to display a page only for the first time.i.e when the user logs in for the first time it should ask to change the password but when the user logs in after changing the password it should not display the changepassword page instead it should redirect to another page.I have used session variables to do this but after the session expires its again showing the change password page.
I am trying to fetch data like Amazon or other sites. The process take time (about one or more hours) to fetch data. But in between the browser get off saying 'Page can not be displayed' in IE and other error in FF and all UI got lost. How to increase browser time to complete the task successfully.
how to display the All countries date and time in C# I have one dropdown list and one label and one submit button in DropDown list i have add all countries list like GMT + 05:30 Chennai, Kolkata, Mumbai, New Delhiwhen i select the particular list and press submit button to display.
I created the form in which i am showing count down time in label.
below is the code
[Code]....
Even i show the time in various format means Hour, Seconds, Tick but difficulty is that i want to show time in "hh:mm:ss" format & Time in label will be decreasing.
I am having two text box for "Password" and "confirm password".
The password should be minimum of 6 charecters.
when the password is minimum of 6 charecter it shows a error message and when the confirm password and password is not matching it shows the error message.
It displays both the error message at a time.
Is there is way to display one by one.
I am using following regular expression validater to validate for minimum of 6 charecter
" <asp:RegularExpressionValidator ValidationGroup="vgProductDetails" ValidationExpression="^([a-zA-Z0-9]{6,10})$" ErrorMessage="Password Should be minimum of 6 Characters and maximum of 8 characters." SetFocusOnError="true" ControlToValidate="txtPassword" ID="RegularExpressionValidator4" runat="server"></asp:RegularExpressionValidator>"
For comapring the password and confirm password, i am using the following.
"<asp:CompareValidator SetFocusOnError="true" ID="CompareValidator2" runat="server" ControlToValidate="txtconfirmPassword" ControlToCompare="txtPassword" ErrorMessage="Password and confirm password should be same."></asp:CompareValidator>"
I am having 3 lable and i need to display in following format
lbl1.text= Fri 4/20 (Today) =>should display the Today's date in the following format lbl2.text= Thu 4/19 (Yesterday)=> display the yesterday date. lbl3.text = Wed 4/18= >Day before yesterday .