Page 1 of 1

Local Time

Posted: Sun Nov 13, 2005 3:14 pm
by us3rX

Code: Select all

$f = "
<html><head><script type='text/javascript'>
var d = new Date()
document.write(d.getHours())
</script></head></html>
";
$h = $f;

if ($h > 6 and $h < 18)
{
	$theme_dir = "new-images/nav-light";
}
else
{
	$theme_dir = "new-images/nav-dark";
}
any one know why that wont work? if i change it to make it echo instead of setting it to $f it will work....

us3rX /ph34r.gif' class='bbc_emoticon' alt=':ph34r:' />

Local Time

Posted: Mon Nov 14, 2005 3:46 am
by Scott
That quite simply, won't work. /blush.gif' class='bbc_emoticon' alt='(blush)' />

This does:

cookie.js:

Code: Select all

function setCookie(name,value)
{
var exdate=new Date()
exdate.setTime(exdate.getTime()+(3600*1000))
document.cookie=name+ "=" +escape(value)+ "; expires="+exdate
}

function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else
	{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}
index.php (or whatever):

Code: Select all

<html>
<head>
<script src="cookie.js" type="text/javascript"></script>
<script>
var c = getCookie('h')
var d = new Date()
var h = d.getHours()
setCookie("h", h)
if (c == null) {
	window.location.href="test.php"
}
</script>
</head>
<body>
<?php
echo $_COOKIE['h'];
?>
</body>
</html>
I think you'll be fine from now on in /smile.gif' class='bbc_emoticon' alt=':)' />

Local Time

Posted: Mon Nov 14, 2005 8:42 am
by us3rX
thank you, again scott /biggrin.gif' class='bbc_emoticon' alt=':D' />

us3rX /ph34r.gif' class='bbc_emoticon' alt=':ph34r:' />