feck Posted December 28, 2006 Share Posted December 28, 2006 I would like someway of being able to enter a specific time frame into a website in the form of minutes ie:60 mins and then for the system to be able to output 4 times calculated from a specific time say midnight 0:00am.So the output into variables would be something like:time1 = 00:00;time2 = 01:00;time3 = 02:00;time4 = 03:00;if input was 60.Is there anyway to do this using javascript or php? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 2, 2007 Share Posted January 2, 2007 You can do it with either Javascript or PHP. For Javascript, you will need to use date objects. Here are a few references for that:http://devguru.com/technologies/javascript/10585.asphttp://javascript-reference.info/#dateFor PHP, there are several date functions. You can use Unix timestamps to handle everything, and add whatever you want to add. The mktime function will get the timestamp for a specific date:http://www.php.net/manual/en/function.mktime.phpAnd then you can just add your time to it. Timestamps are in seconds, so if you want to add 1 hour you would add (60*60) to the timestamp, since there are 60 seconds in a minute and 60 minutes in an hour. And then you can use the getdate function to convert the timestamp into an array where you can read the time, day, month, etc.http://www.php.net/manual/en/function.getdate.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now