?
Solved

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

Posted on 2014-09-11
4
Medium Priority
?
198 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

752 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