0

I am working on my python code as I want to calulcating on the program time to convert it into minutes. When the program start at 12:00AM and my current time show as 1:00AM. The end time show for the program is 6:00AM, so I want to work out between 1:00AM and 6:00AM to take it away then multiply it by 60 to convert it into minutes.

Example: 6 take away 1 which is 5 then I want to multply it by 60 which it is 300 minutes.

Here is the code:

current_time = int(time.strftime("%M")) prog_width = self.getControl(int(program_id)).getWidth() prog_length = int(prog_width) / 11.4 - current_time prog_length = str(prog_length) prog_length = prog_length.replace('.0', '') prog_length = int(prog_length) print prog_length 

Can you please show me an example of how I can calculating between 1:00AM and 6:00AM to take it away then convert it into minutes when multply by 60?

2
  • does anyone know how I can calculating the time between 1:00AM and 6:00AM to take it away then multply by 60 to convert it into minutes? Commented Feb 24, 2016 at 19:26
  • I don't see how the code you show has anything to do with the problem you describe. Commented Feb 24, 2016 at 19:59

1 Answer 1

1

You can use the datetime module

from datetime import timedelta start = timedelta(hours=1) end = timedelta(hours=6) duration = end - start print duration.total_seconds() / 60 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.