Jump to content

Recommended Posts

Js would be easier but its not Server time

 

i think he wanted server time for some reason

 

Js way

<div id="digitalclock" style="float:left;width:400px;"><script language="javascript">calctime();</script></div>

function calctime()
{
var currenttime = new Date();
var day = currenttime.getDay();
var hours = currenttime.getHours();
var minutes = currenttime.getMinutes();
var seconds = currenttime.getSeconds();
var day = currenttime.getDay();
var month = currenttime.getMonth();
var weekday= currenttime.getDate();
var year= currenttime.getYear();

if (year < 2000)
year = year + 1900;

hours = currenttime.getHours();
if (hours >= 12) {
hours = (hours == 12) ? 12 : hours - 12; timesuffix = " PM";
}
else {
hours = (hours == 0) ? 12 : hours; timesuffix = " AM";
}
if (minutes < 10)
{
minutes = "0" + minutes;
}
if (seconds < 10)
{
seconds = "0" + seconds;
};
arday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
armonth = new Array("January ","February ","March ","April ","May ","June ","July ","August ","September ", "October ","November ","December ")
ardate = new Array("0th","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st");
var clocklocation = document.getElementById('digitalclock');
clocklocation.innerHTML = hours + ":" + minutes + ":" + seconds + " " + timesuffix + ", " + arday[day] +", " + armonth[month] +" "+ardate[weekday] + ", " + year;
setTimeout("calctime()", 1000);
}


Link to comment
https://forums.phpfreaks.com/topic/129980-solved-server-time/#findComment-674423
Share on other sites

Yes, but then he has to figure in timezone manipulation for each user.  Oh, the javascript says this users time is this.  That relates to the server time like so, thus the updates will be done at this time (in users time zone).

 

His way says:

 

Here is what time it is at our server location:  ##:##

Here is when the updates will be done in relation to our server time:  ##:##

Link to comment
https://forums.phpfreaks.com/topic/129980-solved-server-time/#findComment-674617
Share on other sites

Yes, but then he has to figure in timezone manipulation for each user.  Oh, the javascript says this users time is this.  That relates to the server time like so, thus the updates will be done at this time (in users time zone).

 

His way says:

 

Here is what time it is at our server location:  ##:##

Here is when the updates will be done in relation to our server time:  ##:##

 

exactly, I have on my server

 

Server time is 10/25/2008 6:21 PM

 

An update will be done on 10/25/2008 6:21 PM

 

Link to comment
https://forums.phpfreaks.com/topic/129980-solved-server-time/#findComment-674719
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.