datetime

Python timedelta in years

I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years. ...

Timezone issue PHP 5.2 Windows (WAPP stack)

On a Win2k server, using a WAPP stack (Windows,Apache,PostgreSQL,PHP). Running a PHP web application. Also tested using PHP interactive console. The datetime is reported correctly, but for some strange reason the timezone is reported incorrectly: php -a <?php echo date('c'); 2009-04-19T16:52:35-04:00 C:\WAPP\php>time /t 17:06 C:\...

Python speed testing - Time Difference - milliseconds

What is the proper way to compare 2 times in Python in order to speed test a section of code? I tried reading the API docs. I'm not sure I understand the timedelta thing. So far I have this code: from datetime import datetime tstart = datetime.now() print t1 # code to speed test tend = datetime.now() print t2 # what am I missing? # ...

Is there a better way in C# to round a DateTime to the nearest 5 seconds?

Hi all, I want to round a DateTime to the nearest 5 seconds. This is the way I'm currently doing it but I was wondering if there was a better or more concise way? DateTime now = DateTime.Now; int second = 0; // round to nearest 5 second mark if (now.Second % 5 > 2.5) { // round up second = now.Second + (5 - (now.Second % 5));...

remove 5 hours from the time

I'm using strtotime to create a timestamp from some ropey XML, but the timezone is incorrect. How can I remove 5 hours from the time? ...

How to calculate the number of months between two DateTimes?

Requirements: Calculate the number of months between two dates: receiveDate and dueDate. Both optimistic and pessimistic calculations are needed Assumptions: dueDate will always be the last day of the month. I've already figured out the pessimistic calculation (meaning a single day overdue counts as a whole month: if(receiveDate...

How Accurate is DateTime.AddDays?

Since DateTime.AddDays() takes a double parameter, I'm concerned that when you add a days, there might be some rounding errors. For example let's say I have the following loop: DateTime Now = DateTime.Today; for (int i = 0; i < 365; ++i) { Now = Now.AddDays(1); // do something } I'm concerned that Now might start drifting away...

DateTime Object Representing Day of Week

How can I convert a number between 1 and 7 into a DateTime object in C# which represents the day of the week? The numbers are coming from a XML file which I am parsing. I am retrieving each instance of a field containing a number between 1 and 7 which represents a day of the week between Sunday and Saturday. ...

How to change mm/dd/yyyy to desired format

hi guys, I have date in format mm/dd/yy.For eg:4/1/2009 means April 1 2009.I want to get format as April 1,2009 in sql.Can anybody help? ...

Does the C# Convert.ToDateTIme function read date as "dd/mm/yyyy" or "mm/dd/yyyy"?

Does the C# Convert.ToDateTIme function read date as "dd/mm/yyyy" or "mm/dd/yyyy"? I have the same application on my local machine which I uploaded to my remote shared server. It was working perfectly on my local machine reading "dd/mm/yyyy", but on my remote machine, it seems to read dates as "mm/dd/yyyy". I have the same culture setti...

How to display difference between two dates as 00Y 00M

Given two DateTimes in C#, how can I display the difference in years and months? I can do basic arithmatic on the timespan that comes from a simple subtraction but this won't take into account the differing lengths of months, leap years etc. Thanks for any help. ...

php microseconds

Hi to all I'm using echo date('H:i:s')." this step time\n"; in order to know how much time needs for each function in order to be executed. How can I know the time with microseconds also? ...

Cannot convert type 'string' to 'System.DateTime'

Trying to do the following: order.ExpirationDate =(DateTime) ( ExpMonth + "/" + ExpYear); ExpMonth, Expyear are both ints. ...

Django admin display groups horizontally

How do I get Django admin to display groups horizontally? If I have 3 adjacent datetime fields, I'd rather them take up 1 row, not 3. ...

Eval strips time segment of a SQL DateTime field

Was going to call this "Eval won't give me the Time of Day," but thought that too cute. I'm kind of having the opposite problem from the suggested questions I see for my title, so here goes: Visual Studio 2008 Pro, SQL Express 2008, Vista. Web Project, where I'm opening records from an Event Table with JOINed info from a Facilities tab...

PHP converting date format

Duplicate Managing date formats differences between PHP and MySQL PHP/MySQL: Convert from YYYY-MM-DD to DD Month, YYYY? Format DATETIME column using PHP after printing date formatting in php Dear All, I have a PHP page where i wil be displaying some data from Mysql db. I have 2 dates to display on this page.In my d...

MembershipUser constructor expects dateTime fields that might be null

The MemberShipUser constructor expects dateTime fields like lastLoginDate, which may be null in the data store. However, when I retrieve data from the store and pass null in for the parameter, I get an error that it cannot be null. How can I work around this? ...

setTimeout but for a given time

Is there anything readily available in JavaScript (i.e. not through "plugins") that allows me to do something like setTimeout, but instead of saying in how many milliseconds something should happen, I give it a date object telling it when to do something? setToHappen(function () { alert('Wake up!'); }, new Date("...")); And yes, I...

I need yyyy-mm-dd hh:mm:ss in SQL Server to become yyyy-mm-dd in C#

HI, This might be a frequent question. I have a date column (InvDate) in SQL Server 2005 database, which has a value like 2009-04-23 00:00:00.000. I am fetching this into a Dataset. Now i need to store only 2009-04-23 into some output Excel sheet (i am using OleDB). I dont want the time , even if it is just 00:00:00.000. I have tri...

Unexpected java SimpleDateFormat parse exception

I can't understand why this few lines Date submissionT; SimpleDateFormat tempDate = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy"); public time_print(String time) { try { submissionT=tempDate.parse(time); } catch (Exception e) { System.out.println(e.toString() + ", " + tim...