save time zone

I need the following for my wordpress site.
1. Something that shows my time with a label (i.e. This is My Time CST -6).
2. Something that will allow an outsourcer to select their time from a list on the front-end, and save it on the page for easy reference.
rtod2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KalpanCommented:
please try to add as below

The accuracy of the local time zone offset value is dependant upon the local user to correctly set this for their own PC. Otherwise, the local time zone offset is already expressed, in JavaScript, as a positive or negative number of minutes.

So, using this cookie-setting JavaScript function:

function setCookie(name, value) {
var argv = setCookie.arguments;
var argc = setCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape(value.replace(/ /g, "+")) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
You can create the desired cookie, and value, as follows:

x = new Date();
currentTimeZoneOffsetInHours = x.getTimezoneOffset() / 60;
setCookie("LOCAL_TIME_ZONE_OFFSET", currentTimeZoneOffsetInHours);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rtod2Author Commented:
Thank you for the code.  I have never done anything with cookies so I wouldn't know how to implement your suggestion.

From the back-end of Wordpress, I would:
1) Add New Page
2) Paste code ??

Your assistance is greatly appreciated.
Ray PaseurCommented:
You might want to hire a professional developer to help with this.  It's not completely simple.

The PHP and MySQL part of things are explained here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

HTH, ~Ray
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

rtod2Author Commented:
Maybe part one is just to show 'my time' statically.  Can I do that without code?
Ray PaseurCommented:
"without code?" - Uhh, maybe you mean "In JavaScript without any modifications to PHP on the server?"
rtod2Author Commented:
Not sure what I mean.  What are the steps to get "My Time" to show up on the page.

Example:

1. My Time is -6 UTC and is currently ??

What is Your Time currently ??

If I could set 1 up then I can take it from there and figure out a workable solution.
Ray PaseurCommented:

<?php // RAY_easy_client_time.php
error_reporting(E_ALL);


// USE JAVASCRIPT TO GET THE CLIENT TIME AND COMPUTE THE OFFSET FROM THE SERVER TIME


// LOCATION OF THE SERVER - COULD BE ANYWHERE
date_default_timezone_set('America/Denver');

// DIFFERENCE OF SERVER TIME FROM UTC
$server_offset_seconds = date('Z');

// WHEN THE FORM IS SUBMITTED
if (!empty($_POST))
{
    // JAVASCRIPT TELLS US THE CLIENT TIME OFFSET FROM GMT / UTC
    $client_offset_minutes = $_POST["date_O"];
    $client_offset_seconds = $client_offset_minutes * 60;

    // THE TIME WE WANT AT THE CLIENT LOCATION
    $client_timestring = 'TODAY 7:00AM';

    // MAKE THE COMPUTATIONS, INCORPORATING THE OFFSET FROM GMT
    $client_timestamp  = strtotime($client_timestring) + $client_offset_seconds;
    $server_timestamp  = $client_timestamp + $server_offset_seconds;
    $server_timestring = date('l, F j, Y \a\t g:i a', $server_timestamp);

    echo "<br/>ACCORDING TO THE VALUE FROM PHP date Z";
    echo "<br/>SERVER IS LOCATED $server_offset_seconds SECONDS FROM UTC";
    echo "<br/>";

    echo "<br/>ACCORDING TO THE VALUE FROM JS dateObject.getTimezoneOffset()";
    echo "<br/>CLIENT IS LOCATED $client_offset_minutes MINUTES FROM UTC";
    echo "<br/>";

    echo "<br/>WHEN IT IS '$client_timestring' AT THE CLIENT, IT IS '$server_timestring' IN " . date_default_timezone_get();
}

// END OF PHP - USE HTML AND JS TO CREATE THE FORM
echo PHP_EOL; ?>

<form method="post">
<input name="date_O" id="dateTime_O" type="hidden" />
<input type="submit" value="CHECK CLIENT DATETIME" />
</form>

<!-- NOTE THIS WILL GIVE YOU THE VALUES AT PAGE-LOAD TIME, NOT AT SUBMIT TIME -->
<!-- MAN PAGE REF: http://www.w3schools.com/jsref/jsref_obj_date.asp -->
<script type="text/javascript">
var dateObject = new Date();
document.getElementById("dateTime_O").value = dateObject.getTimezoneOffset();
</script>

Open in new window

rtod2Author Commented:
Need something simpler than that.  This is making a mountain out of a molehill I think.  Sorry to put it like that.  I do appreciate all the help!
Ray PaseurCommented:
As I wrote above, "You might want to hire a professional developer to help with this.  It's not completely simple."

It doesn't get any simpler than that.  Install the script on your server and run it to see the moving parts.  Watch the values that you get from running it and you should be able to see how it works.
rtod2Author Commented:
Would I paste your code here
del.png
Ray PaseurCommented:
Please hire a professional developer to help with this.  I have shown you the principles, but if you cannot implement them, then it's not really a question as much as it is a need for an application developer -- to modify your current (working) code.  Suggest you get on Facebook and look up Aaron Brazell.  I know him personally - tell him I sent you.  He is a good guy and he recently wrote a book on Wordpress.  Located in Austin, TX, Central Standard Time (UTC - ?).  Aaron is not cheap, but he is the best in the game and you will get good and timely results.  Show him the communications we have shared here.  You'll have a clearheaded working solution in an hour or two!

Good luck and Happy New Year, ~Ray
rtod2Author Commented:
Well the question for this is certainly not something I would pay for but I might indeed be interested in having him tell me what he can do for me.

In terms of this question, it is still pending.
rtod2Author Commented:
Your code below produced a button at the bottom here >> http://tedpenner.com/test-clock/ but the rest of it is still troubling.
<?php // RAY_easy_client_time.php
error_reporting(E_ALL);


// USE JAVASCRIPT TO GET THE CLIENT TIME AND COMPUTE THE OFFSET FROM THE SERVER TIME


// LOCATION OF THE SERVER - COULD BE ANYWHERE
date_default_timezone_set('America/Denver');

// DIFFERENCE OF SERVER TIME FROM UTC
$server_offset_seconds = date('Z');

// WHEN THE FORM IS SUBMITTED
if (!empty($_POST))
{
    // JAVASCRIPT TELLS US THE CLIENT TIME OFFSET FROM GMT / UTC
    $client_offset_minutes = $_POST["date_O"];
    $client_offset_seconds = $client_offset_minutes * 60;

    // THE TIME WE WANT AT THE CLIENT LOCATION
    $client_timestring = 'TODAY 7:00AM';

    // MAKE THE COMPUTATIONS, INCORPORATING THE OFFSET FROM GMT
    $client_timestamp  = strtotime($client_timestring) + $client_offset_seconds;
    $server_timestamp  = $client_timestamp + $server_offset_seconds;
    $server_timestring = date('l, F j, Y \a\t g:i a', $server_timestamp);

    echo "<br/>ACCORDING TO THE VALUE FROM PHP date Z";
    echo "<br/>SERVER IS LOCATED $server_offset_seconds SECONDS FROM UTC";
    echo "<br/>";

    echo "<br/>ACCORDING TO THE VALUE FROM JS dateObject.getTimezoneOffset()";
    echo "<br/>CLIENT IS LOCATED $client_offset_minutes MINUTES FROM UTC";
    echo "<br/>";

    echo "<br/>WHEN IT IS '$client_timestring' AT THE CLIENT, IT IS '$server_timestring' IN " . date_default_timezone_get();
}

// END OF PHP - USE HTML AND JS TO CREATE THE FORM
echo PHP_EOL; ?>

<form method="post">
<input name="date_O" id="dateTime_O" type="hidden" />
<input type="submit" value="CHECK CLIENT DATETIME" />
</form>

<!-- NOTE THIS WILL GIVE YOU THE VALUES AT PAGE-LOAD TIME, NOT AT SUBMIT TIME -->
<!-- MAN PAGE REF: http://www.w3schools.com/jsref/jsref_obj_date.asp -->
<script type="text/javascript">
var dateObject = new Date();
document.getElementById("dateTime_O").value = dateObject.getTimezoneOffset();
</script>

Open in new window

rtod2Author Commented:
Here it is a test site.  Not exactly what I was after but a good tool none-the-less.  I tried to make the question clearer here >>  http://onodot.com/xtro
Ray PaseurCommented:
At http://tedpenner.com/test-clock/ it appears that you have pasted my code into a text area of an HTML page.  What were you expecting?  It is a standalone PHP script that is a teaching demonstration of how to get the client's time from the client's computer.  You just install it and run it.  Here is a link to the example:
http://www.laprbass.com/RAY_easy_client_time.php

Regarding this, "In terms of this question, it is still pending." -- That is why you need to hire a professional developer!  The question is completely answered, with working and tested demonstration code, and now all you need is someone to take the knowledge demonstrated in that answer and integrate it into your unique application environment.  I can only teach the principles; I can't do application changes for you.
onodot.png
Ray PaseurCommented:
Sidebar note... WordPress is written in PHP.   If you decide you want to learn PHP, this is a really good book to get you started.
http://www.sitepoint.com/books/phpmysql4/
rtod2Author Commented:
Thanks Ray,
I'm new to this.  This project is not up for hire.  Thank you for the learning resources.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.