Solved

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

Posted on 2014-09-11
4
181 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
  • 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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…
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.…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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