Solved

Get current time and print the last top or bottom of hour

Posted on 2014-09-11
4
188 Views
Last Modified: 2014-09-11
Hi

I need to find out the time and then print out the top or bottom of hour.

Example:   Time is 10:40
Print: 10:30

Example:   Time is 11:01
Print: 11:00
0
Comment
Question by:mikeysmailbox1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40318152
use POSIX;
@t=localtime;
$t[1]=floor(t/30)*30;
print strftime "%H:%M\n",@t;
0
 
LVL 1

Author Comment

by:mikeysmailbox1
ID: 40318267
Hi ozo,

That is partly working. It is working from 01 to 29 and setting it to 00 but when its 31 to 59 its setting to 00 also when it
should be 30

Thanks
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40318272
$t[1]=floor($t[1]/30)*30;
0
 
LVL 1

Author Closing Comment

by:mikeysmailbox1
ID: 40318284
That worked great. Thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question