Geekzone: technology news, blogs, forums
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

80 posts

Master Geek
+1 received by user: 1

Topic # 65262 1-Aug-2010 10:18
Send private message

I'm using Geektool on my Mac to display info about my computer on my desktop, plus some date and time info. I'm trying to find a script that will display a time in hours since a certain time (4.30pm, July 28, 2010).
I don't have any experience with this stuff but I have managed to find a code that can display a time in days;

python -c 'from datetime import *; print (date(2010, 07, 28) -'

Is there any way this can be adjusted for a time in hours?

Create new topic
1 post

Wannabe Geek

  Reply # 361298 2-Aug-2010 04:36
Send private message


Try this :

# This script returns the number of hours since a certain date and time

NOW=`date +%s`

echo $(( ($NOW-$REFERENCE_TS) / 3600 ))

80 posts

Master Geek
+1 received by user: 1

  Reply # 362740 4-Aug-2010 07:05
Send private message

Yep, that is exactly what I was after. Thanks!

Create new topic

Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:

Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:

Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:

Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.