Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

828 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