Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now