How can I do a function that gets the current time then compares the current time with times from a page, and highlights the lowest time, for example:
06:00
06:10
06:30
06:45
if the current time is 06:00, then hightlight 06:00
Any help would be great appreciated.
Simple date function
Moderator: General Moderators
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Simple date function
The first thing I did is to get the time(i need the time from the server):
function ttime() {
var ttime='<?php echo date("H:i", time())?>';
}
function ttime() {
var ttime='<?php echo date("H:i", time())?>';
}
Re: Simple date function
24 hour clock?
Make a numeric equivalent of each time (600, 610, 630, 645), find the lowest one, then highlight it somehow (changing the text colour, background colour, etc)
Make a numeric equivalent of each time (600, 610, 630, 645), find the lowest one, then highlight it somehow (changing the text colour, background colour, etc)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Simple date function
Yeah thnx but I don't know how to do it in javascript, I did it in php but now I want to convert to js.
Re: Simple date function
Post your PHP code.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Simple date function
I can't paste the code here, but it goes something like this:
it gets 2 time records from the db, and checks if the time now is between those 2.
I am imaging that in javascript, to get all this times by class name and put in an array, and then do the comparison
it gets 2 time records from the db, and checks if the time now is between those 2.
I am imaging that in javascript, to get all this times by class name and put in an array, and then do the comparison
Re: Simple date function
Sounds about right. If you can't post your PHP code, I can't help you convert it to Javascript. Do some investigation into the Javascript Date() object & you might be able to figure it out.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.