-
Time zone stamp
This is a function used in a “js” file for the chat box on my forum. The code between the rows of “+” simply format and add a timestamp to each post in the chat box. The time posted is each member’s local time; I wanted to have the time zone after the time. The time appears as it should, but I cannot get the time zone to show. I have tried the code in red, but all crash the chat box.
You can see the chat box at my site; 3w.ddscart.org
My question is; how do I make the time zone show.
function postText()
// ++++++++++++++++++++++++++++++++++
{
var timestamp;
var A_P; // am or pm
var H_r; // hour
var M_i; // minute
var T_z; // timezone
time = new Date ();
M_i = time.getMinutes();
H_r = time.getHours();
A_P = ""; // Had to clear to stop improper readings – why?
// T_z = system.getTimeZone();
// T_z = time.getTimeZone();
// T_z = date.getTimeZone();
// T_z = calender.getTimeZone();
{
if (M_i < 10)
{
(M_i = "0" + M_i); // add leading zero to min if single digit
}
}
{
if (H_r < 12)
{
(A_P = "am"); // set am-pm to am
}
}
{
if (H_r > 11)
{
(A_P = "pm"); // set am-pm to pm
}
}
{
if (H_r > 12)
{
(H_r = H_r-12); // change 24 hr to 12 hr system
}
}
{
if (H_r < 1)
{
(H_r = 12); // if hour = 0, change hour to 12
}
}
// timestamp = " " + H_r + ":" + M_i + " " + A_P + " " + T_z + " : ";
timestamp = " " + H_r + ":" + M_i + " " + A_P + " : ";
// ++++++++++++++++++++++++++++++++++++++
rnd++;
chatbox = getElement( "mytext" );
chat = chatbox.value;
chat = timestamp + chat;
chatbox.value = "";
userid = location.search.substring( 1, location.search.length );
url = 'Server.aspx?action=PostMsg&u=' + userid + '&t=' + encodeURIComponent(chat) + '&session=' + rnd;
req = getAjax();
req.onreadystatechange = function()
{
if( req.readyState == 4 && req.status == 200 )
{
updateAll();
}
}
req.open( 'GET', url, true );
req.send( null );
}
Thanks
-
No ideas?
Is there a system api call? Am I doing anything right? Am I even working in the right direction?
Must be someone who will help out!
Thanks