Jump to content

Time


Fincikas

Recommended Posts

do you have root server access to change the time? is it a windows or linux based server? More importantly,  is changing the system time going to do what you want? No.

 

User time is never reflected on the server.  If you post a newsblog at 5pm local time, and the server is in Romania, using PHP's date and time functions will store the server's time.  When you recall that time, all users will see the server's time.  To get around this, many developers  take a few steps:

 

[*] Setting a "standard" time offset for the application.  If you live in the east coast and your readers are typically from the same area, this would be EST (-5) / EDT (-4)

[*] Users set up their own preference to time zone which creates another offset

[*] When saved to the database, the newsblog's time is created to GMT (+0)

[*] When recalling the timestamp from the database, if there is a logged in user with offset preference, the math is applied accordingly

[*] Else, the application's standard time is used (-5 in this instance)

Link to comment
Share on other sites

Im creating coutdown timer, so if user changes his time on PC it changes in timer too. Could you write any code to help me out, because im using default time zone ant ect. Even if its in the server(hosting) it still changes, but Im mainly working on wamp server now.  It is Javascript now, but if I could set undisturbiable default server time, I know how to solve it. Code:

 

<html>

<head>

<script type="text/javascript">

function cdtd() {

var xmas = new Date("December 25, 2012 00:01:00");

var now = new Date();

var timeDiff = xmas.getTime() - now.getTime();

if (timeDiff <= 0) {

        clearTimeout(timer);

document.write("Christmas is here!");

// Run any code needed for countdown completion here

    }

var seconds = Math.floor(timeDiff / 1000);

var minutes = Math.floor(seconds / 60);

var hours = Math.floor(minutes / 60);

var days = Math.floor(hours / 24);

hours %= 24;

    minutes %= 60;

    seconds %= 60;

document.getElementById("daysBox").innerHTML = days;

document.getElementById("hoursBox").innerHTML = hours;

document.getElementById("minsBox").innerHTML = minutes;

document.getElementById("secsBox").innerHTML = seconds;

var timer = setTimeout('cdtd()',1000);

}

</script>

</head>

<body>

Days Remaining:

<div id="daysBox"></div>

Hours Remaining:

<div id="hoursBox"></div>

Minutes Remaining:

<div id="minsBox"></div>

Seconds Remaining:

<div id="secsBox"></div>

<script type="text/javascript">cdtd();</script>

</body>

</html>

 

BTW thanks for help :)

Link to comment
Share on other sites

Could you write any code to help me out

No. That's not what these forums are for. 

 

I'm certain once a mod moves this to the proper home somebody will help you with that though.

 

SO what are these forums for? Just type some not understandable sentences that PHP master can understand, and u left us beginners alone. You call that help? Ok if you can give me a code, please explain some steps that u wrote before...

Link to comment
Share on other sites

phpfreaks in general is for helping you do stuff. If you want someone to do it for you then try the Freelancing forum. And be prepared to hand over some money.

 

a) Why does it matter if the user gets the timer to expire? It's just JavaScript.

b) Start with the date difference and subtract 1 each second: if the date changes on the client it won't matter.

Link to comment
Share on other sites

SO what are these forums for? Just type some not understandable sentences that PHP master can understand, and u left us beginners alone. You call that help? Ok if you can give me a code, please explain some steps that u wrote before...

Your sentences are incoherent and you haven't written an ounce of PHP.  You have Javascript here and Requinix has given you the advice you sought.  You should say thank you

Link to comment
Share on other sites

Ok, thank you. But I dont understand this:

Start with the date difference and subtract 1 each second: if the date changes on the client it won't matter.

 

How to get date difference? Difference with what? User and server time? How to subtract and from what? From difference? from time? Sorry for my nobeish, sorry for my flame, sorry I dont red rules and ect. but I stuck with this for weeks, Im trying to solve it and cant. And when i joined PHP/Javascript masters forum and they couldnt explain for total noob a thing Im anoyed, so please explain it in detail, no need to write code, but more detailed. THANK YOU

Link to comment
Share on other sites

Im pretty good at PHP, but JavaScript code I got from internet (just copy pasted) and I dont know anything about that , but still thanks for the code and for Unix timestamp name, cause I can start googleing something useful, but if you would mind to save my time and explain where to put, or just to say should I anything put in

/* future timestamp */
.
Link to comment
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.