time

Subtract time on specific lines using php

Using php I'd like to subtract/minus two times; each time within a separate document and thereafter have php write the result (Result after subtracting the two times) within another single text document or within a html document with no HTML tags, just text. The two times subtracted will determine how long a certain player has played the...

Convert Office Hours to local time using JavaScript

How can I use JavaScript to add a message like this to a web page: Our office hours are 9am - 5pm (09:00 - 17:00) PST. In your timezone, that's WWxx - YYzz (AA:00 - BB:00). Where: "WW" and "YY" are converted to the proper values for "hour" (on the 12 hour clock). "xx" and "zz" are converted to either "am" or "pm". "AA" and "...

How to get the time of a given city?

I know that I can display time for a particular location using only JavaScript (and no web service or external data source), but... I want to avoid using this solution because I don't want to have to account for daylight savings time, and any other factors that make it complicated. I'm looking for an easier way to display the time and a...

Representing time differences in Ruby

Does Ruby stdlib have any objects that represent difference between two timestamps? Subtracting two Time object from each other returns a float number of seconds - is there any object for that, with methods like hours, minutes etc., and most of all decent to_s? I've coded half-assed methods for that far too many time, am I doing it wron...

Windows: reliable way to know if a certain date passed?

For a simple product key library I need to reliably check if a certain date passed. I'd like to do something slightly less trivial than checking the system clock since that can be changed easily by the user. What are standard ways of doing this? One way someone suggested is to check if there are files which were modified after the ch...

Format date based on locale in python

I have a date output like >>> import time >>> print time.strftime("%d %B") 19 July Is there a way to format the date based on the locale, but still have control of what is shown (in some cases I don't want the year). For example, on a en_US machine, I want it to output: July 19'th ...

How to "make something" in a specific time and day of the week in java?

I have an application that needs to play some specifics audios(mp3) periodically. Let me give one example: Every Monday at 8:00am -> hello.mp3. How can I do that in Java?? I´m trying using Calendar, JodaTime, but I cant do it. ...

convert month from name to number

Is there an easy way to change $month = "July"; so that $nmonth = 7 (07 would be fine too). I could do a case statement, but surely there is already a function to convert? EDIT: I wish I could accept multiple answers, cause two of you basically gave me what I needed by your powers combined. $nmonth = date('m',strtotime($month)); That...

c++ get milliseconds since some date

Hey folks, I need some way in c++ to keep track of the number of milliseconds since program execution. And I need the precision to be in milliseconds. (In my googling, I've found lots of folks that said to include time.h and then multiply the output of time() by 1000 ... this won't work.) ...

Measure the run time in pascal program

Hi Please, I need to measure the search time in my pascal program in order to measure the performance efficient.. if there is any function or code to measure the search time? thanks ...

python time problem

Hello, I am using the exif.py library. After calling tags=exif.process_file(...) i want to retrieve the time the image was captured. so i continue with t =tags['Image DateTime'] if tags.has_key('Image DateTime') else time.time() now i want to store t in django's database. For that t must be in the form 2010-07-20 14:37:12 but app...

My function takes negative time to complete. What in the world happened?

I'm posing this question mostly out of curiosity. I've written some code that is doing some very time intensive work. So, before executing my workhorse function, I wrapped it up in a couple of calls to time.clock(). It looks something like this: t1 = time.clock() print this_function_takes_forever(how_long_parameter = 20) t2 = time.clock...

Sorting a time value in a dataset

In my current solution, I am converting a DateTime value, "Time" in my database using CONVERT so it displays in a ##:##AM/PM format, and I realize that CONVERT just takes whatever datatype and turns it into a VarChar, or a String once its in C#. This is making my sort work incorrectly in my Gridview. I am sorting the columns in my DataSe...

Check if a given date is past

I have a week calendar that holds events, and want that users can't add events for the past days. So I'm tring to use a function like that: if( strtotime($this->day) < time() ){ // date format is YYYY-MM-DD // date is past }else{ // date is not past } It seems to works fine, except that it consider today date as a past day. What a...

Time within a particular time interval

i'm trying to solve a seemingly simple problem, but just can't quite get my mind around it. i have two times startTime and stopTime, which can be considered to be in the format: hh:mm:ss [24hr format]. Now given a third time - timeToTest - i need to find out if timeToTest lies between startTime and stopTime. There is no date informati...

adding 2 1/2 hours to a time object in python

Hello all, I need to be able to convert time on an time object I recieve from a sql database into python. Here is the current python code I am using without any conversions. I need to add 2 and 1/2 hours to the time. def getLastReport(self, sql): self.connectDB() cursor.execute(sql) lastReport = cursor.fetchall() dat...

Techniques for visualising change over time in graphs

I'm looking to display a graph (network diagram, not a chart) and show its changes over time. Is there a standard or best way to do this? I'm looking for an overview of the general layout decisions involved, i.e. a list of options and trade-offs to be made, and best-practice guidelines where these exist. Thanks. ...

Causing timer to reset to specific amount only after xxx time remains (PHP)

I have a php script I'm trying to alter. The original code is written to increase the countdown timer by a value pulled from SQL anytime a button is pressed. What I've been trying to do is change the code so that the time doesn't increase but actually resets to a specific remaining time ONLY WHEN the timer is under a certain amount (sa...

NSTimer: Getting firing to NOT act retroactively.

Hello Everyone, I'm currently using the snippet of code presented below to fire some methods every second. My app is running in the background. The problem is that if the computer wakes up after a sleep period the timer wants to retroactively fire all the methods it has missed. Similar issues come up if the user were to change the Syste...

What's the learning curve for Android?

What has people's experience been in learning Android? I'd be interested in how long it takes to get to the point where you're writing your first app, and how the experience compares to learning some other programming API. I know several professional programmers who have tried to learn Android and failed. Is it inherently more difficu...