Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

minutes since midnight

Status
Not open for further replies.

ShaneBrennan

Programmer
Joined
May 19, 1999
Messages
198
Location
GB
I'm new to PHP & MySQL and I've got a little problem.

I have a time fields, start_time, in my database, which I can retrieve okay. But I want to calculate the numbers of minutes since midnight.

Any ideas how I could do this - or even better has anyone got a small useful procedure/function.

Any help will be appreciated



Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk


 
What format is start_time? If it's a UNIX timestamp, [tt]$variable % 86400[/tt] should do it.

//Daniel
 
Actually, that would get you the number of seconds since midnight. Divide the result by 60 and you should get the right number.

//Daniel
 
I'm actually curious as to what "minutes since midnight" means.


If I store a datetime value from today in a MySQL table, then perform the calculation tomorrow, what does "minutes since midnight" mean?

Want the best answers? Ask the best questions: TANSTAAFL!
 
I'm trying to create a simple week planner of courses run by a college. The planner is a simple grid of :
rows of the 7 days
columns - 5 minute intervals from 8am till 10pm

Getting the number of minutes from midnight for the start and end times will let me create it. Thats it really.





Shane Brennan

'-----------------------

' Emails: shanebrennan@postmaster.co.uk


 
So, turn start time into a unix time stamp with the mktime() function and then use Daniel's suggestion, or if you prefer then use the mktime function twice, once with the timestamp you have and once with midnight of the same day/month/year.

Make sure to test your solution against daylight savings days.

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top