Page 1 of 1

Local Time

Posted: Sun Nov 13, 2005 11:14 pm
by us3rX
[code]$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";
}[/code]

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 <img src=\'http://www.killanet.net/forum3/public/s ... /ph34r.gif\' class=\'bbc_emoticon\' alt=\':ph34r:\' />

Local Time

Posted: Mon Nov 14, 2005 11:46 am
by Scott
That quite simply, won\'t work. <img src=\'http://www.killanet.net/forum3/public/s ... /blush.gif\' class=\'bbc_emoticon\' alt=\'(blush)\' />

This does:

cookie.js:
[code]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));
}[/code]

index.php (or whatever): [code]<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>[/code]
I think you\'ll be fine from now on in <img src=\'http://www.killanet.net/forum3/public/s ... /smile.gif\' class=\'bbc_emoticon\' alt=\':)\' />

Local Time

Posted: Mon Nov 14, 2005 4:42 pm
by us3rX
thank you, again scott <img src=\'http://www.killanet.net/forum3/public/s ... iggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' />

us3rX <img src=\'http://www.killanet.net/forum3/public/s ... /ph34r.gif\' class=\'bbc_emoticon\' alt=\':ph34r:\' />