![]() |
|
|
#1 (permalink) |
|
Crazy
|
javascript to php?
Hello,
So thanks to the help of JinnKai, I was able to get this excellent piece of code to do exactly what I needed Code:
<script language="JavaScript">
var today = new Date();
var hours = today.getHours();
if (hours >= 0 && hours < 6)
document.write("Midnight");
else if (hours >= 6 && hours <9)
document.write("Prime");
else if (hours >= 9 && hours <12)
document.write("Terce");
else if (hours >= 12 && hours < 15)
document.write("Sext");
else if (hours >= 15 && hours < 18)
document.write("None");
else if (hours >= 18 && hours < 21)
document.write("Vespers");
else
document.write("Compline");
</script>
thanks. |
|
|
|
|
#2 (permalink) |
|
Addict
|
That would be fairly simple to convert to php, the structure wouldn't need to change just a few commands, wrap it in <?php ?>, and document.write becomes echo"";
check on php.net to find out how to use the date function and you don't need to specify var hours for a variable but all variables do need a $ symbol ($hours = Date()) |
|
|
| Tags |
| javascript, php |
|
|