datetime

Most simple way to do holiday calculation?

I want to make a little free calendar program to help me and others calculate how much time we have got left in a project. I mean real working time, not just time. Time in a raw form is not saying much. Typically when my boss tells me that I have time until 05-05-2011 it doesn't tell me really how much time I have to do my job. You kno...

Comparing datetimes does not work

I'm creating a Rails application which uses MySQL. I have a table in my DB like this: create_table "pastes", :force => true do |t| t.string "title" t.text "body" t.string "syntax" t.boolean "private" t.datetime "expire" t.string "password" t.datetime "created_at" t.datetime "updated_at" end...

Why does Safari/Opera not work with this javascript code?

Hi, I am working on a calendar that will show bookings. The height of containing the booking is calculated dynamically in proportion to the length of the booking. The following code works perfectly well in Firefox but not in Safari or Opera: function calculateBookingHeight(from, to) { var today = new Date; var end = new Date....

C# locale-aware MaskedTextBox mask for DateTime values

C# locale-aware MaskedTextBox mask for DateTime values I'm working through FXCop/Code Analysis's Globalization warnings and would like to know the proper, locale-aware way to set and get DateTime values through a MaskedTextBox. My form has a MaskedTextBox element with its Culture property set to "en-US", and its Mask property set to "0...

How to know the date time format used to convert a string to DateTime in C#

Hello All: I am converting a string to datetime using DateTime.TryParse in C#. Can somebody tell me, how to know which format C# compiler used to convert the string to valid DateTime. I want to know the datetime format used. Thanks, Ashwani ...

How to deal with Rounding-off TimeSpan?

I take the difference between two DateTime fields, and store it in a TimeSpan variable, Now I have to round-off the TimeSpan by the following rules: if the minutes in TimeSpan is less than 30 then Minutes and Seconds must be set to zero, if the minutes in TimeSpan is equal to or greater than 30 then hours must be incremented by 1 and Mi...

Insert text depending on time of day and day of week.

I'm trying to piece together a php script to output different text depending on what day it is and the time of day. Example: On weekdays (mon-fri), I would like to output text according to the following periods of time (24H, server time, UTC): 00:00-08:00: "Lorem ipsum" 08:00-13:00: "dolor sit amet" 13:00-15:00: "Pellentesque habitant" ...

How do I best run a search on Date when it is not a :has_many association?

I have a number of activities that have a calculated scheduled date. The activities, for example, Email, have a email.days method which is the days from a Contact.start_date on which it should be sent. This means contact.start_date + email.days yields a date on which email is sent to contact. I would like to use link_to around the dat...

Develop web-services aware of user's time zone

I'm developing a client-server application on java. The server offers some operations through a web service. The application must show some content depending on the user's custom date and time; information that is retrieved from the web service. Different users may be in different time zones. I've been thinking on how to store on the se...

Python: Figure out local timezone

I want to compare UTC timestamps from a log file with local timestamps. When creating the local datetime object, I use something like: >>> local_time=datetime.datetime(2010, 4, 27, 12, 0, 0, 0, tzinfo=pytz.timezone('Israel')) I want to find an automatic tool that would replace thetzinfo=pytz.timezone(...

Why are my two date fields not identical when I copy them?

I use django, and have two models with a models.DateTimeField(). Sometimes I need a copy of a date - but look at this: >>>myobject.date = datetime.datetime.now() >>>print myobject.date >>>2010-04-27 12:10:43.526277 >>>other_object.date_copy = myobject.date >>>print other_object.date_copy >>>2010-04-27 12:10:43 Why are these two date...

Convert Date String to DateTime Object in Python

Ok, so I have this date: 2005-08-11T16:34:33Z I need to know if this is date is before or after datetime(2009,04,01) and I can't seem to find a method that will convert that string to something that lets me compare it to datetime(2009,04,01) in a meaningful way. Surely there must be some built in method. I mean if I can't find one, I ...

MySQL: Get average of time differences?

I have a table called Sessions with two datetime columns: start and end. For each day (YYYY-MM-DD) there can be many different start and end times (HH:ii:ss). I need to find a daily average of all the differences between these start and end times. An example of a few rows would be: start: 2010-04-10 12:30:00 end: 2010-04-10 12:30:5...

Datetime and date-range comparsion

Hello guys, I have datetime-row in mysql database. I have to check time between now and that date using php. If the range is bigger then 1 month - do somtething. I tried something like this: $dateFromMysql = strtotime($rowData); $currentDate = date("m/d/y g:i A"); And then comparsion by hands. It's ugly. ...

"could not resolve property" exception while adding criteria for DateTime property

public class Entity { public virtual string Title { get; set; } public virtual DateTime CreationDate { get; set; } public virtual int Count { get; set; } } I have a problem when creating Criteria for a given entity: var s = session.CreateCriteria<Entity>() .Add(Expression.Ge("CreationD...

Mysql - NOW() function calling

Hello, I'm using php for making queries for mysql. Here is one: UPDATE `subscribers` SET `curDate` = NOW() WHERE `e_mail` = "$resEmail" curDate - DateTime type. The problem is that after this query curDate of given email is 0000-00-00 00:00:00 What's wrong? ...

How to Compare a Time String with DateTime.Now

I have time from DB: string user_time = "17:10:03"; //Hours:minutes:seconds DateTime time_now = DateTime.Now; How do I compare the time? How make same like this: if(time_now > user_time) { //Do something } else { //Do something } ...

Date Functions details needed by month wise

I want to find out the people from 2009 jan to dec 2009 by month wise using date(timestamp) attribute ...

how to convert the datetime value to hour

I have datetime value as 2010-04-07 09:00:00.000 2010-04-07 14:30:00.000 how to convert the 14:30 to 2:30 pm ...

How to set 12 hour clock format for the entire iPhone application?

I would like to set the 12 hour clock format for my entire iPhone application irrespective of whether the user has set the iPhone device clock format to 12 hrs or 24 hrs. Please advise as to how this can be achieved. ...