datetime

Call a method at a specific time for Django/Python?

Hello, In my Django web app, an event's status changes from 'upcoming' to 'completed' at a certain date/time. However, I want to update the database as soon as the event object's date/time has passed. Any ideas how I would code this? My only idea so far is to have a thread constantly running that that checks to see if the event object'...

Convert Python datetime to rfc 2822

I want to convert a Python datetime to a an RFC 2822 datetime. I've tried these methods to no avail: >>> from email.Utils import formatdate >>> import datetime >>> formatdate(datetime.datetime.now()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/System/Library/Frameworks/Python.framework/Versions/2.6...

Add milliseconds to Java date, when milliseconds is long

Hi guys, I am looking for the best way to add milliseconds to a Java Date when milliseconds is stored as a 'long'. Java calendar has an add function, but it only takes an 'int' as the amount. This is one solution I am proposing... Calendar now = Calendar.getInstance(); Calendar timeout = Calendar.getInstance(); timeout.setTime(toke...

Convert 12hr date/time string to 24hr datetime

Like other questions asked here, im looking to do a simple conversion of time formats. I've found answers on how to do this in Perl, but not in Python. I have a string like so: on Jun 03, 02010 at 10:22PM and I'd like to convert it to a datetime object like this: Thu, 03 Jun 2010 22:22:00 -0000 I have sliced up my input like so: ...

Code for fuzzy date to absolute date?

I need code that takes in a string and determines the date. I wrote a simple 15line function to return the date assuming it is relative. That was easy. Now i need to take in a string such as "jan 17 09" "1/2/3" (is it MM/DD/YY? or DD/MM/YY, here it means the former). I'll need ambiguous return codes or exceptions. What can i use to parse...

Given a day and month, return the most recent date of that day and month in the form day-month-year

Given a date like "4 May", how do I get the most recent 4th May in the format "4 May, 2010"? If the day/month combination has not yet occurred this year, it should show the date for last year (e.g. "31 December" should translate to "31 December, 2009"). ...

ASP.NET Javascript DateTime TimeZone Issues

Hi All, I am having an issues passing a JSON containing DateTime to asp.net code-behind (c#). If the client browser is in the same timezone as the server I have no issue, but if they are in different timezones my time is getting modified by the offset value of the two timezones. But all my datetimes need to be the date with a time of ...

DateTime.ToString("h") causes exception!

Open a watch window new DateTime(2010,01,01).ToString("h") Gives: new DateTime(2010,01,01).ToString("h") threw an exception of type System.FormatException Yet... new DateTime(2010,01,01).ToString("h ") Gives: "12 " So why does an extra space stop this format exception from happening? Is this a bug? ...

.NET date formatting

Consider: Assert.Equal("11 Aug 2010", date.ToString(???); Somehow ToString("d MMM yyyy") outputs "11 aug 2010". How can I make it to be Aug instead of aug? ...

Using DateTime in a For loop, incrementing date Isn't working

I have this loop, its purpose is to loop through a range of dates and perform some logic to automate adding entries into the database. The issue is that the incrementing portion, date.AddDays(1.0) isn't working, and is always the same result, causing an infinite loop. Any insight? for (DateTime date = DateTime.Now; futureDate.Compare...

I am trying to convert a date/time string in PHP

I am trying to convert a date/time string in this format YYYY/MM/DD/HH:MM:SS to a format that is recognized in PHP ...

Offer current date in Rails

I want to offer the current date to the user when a new record is created and I want to allow him to edit the offered date. For example I write a bug tracking system and I have a date_of_detection field. 99% of the time it is good if it is the current date, but for the sake of the 1% the user should be allowed to edit it and set any earl...

How to store and retrieve date values

Please i want to Insert data date in "textbox" with PHP to myssql. But i can't do it. And show it with format "dd/mm/yyyy" in table ...

Converting String (in Eastern Daylight Time format) to Date in SQL

Please I need help on how to convert this string [ Fri Jun 19 10:45:39 EDT 2009 ] that is in EDT date format back to Date in SQL (Am using Postgres). I want to be able to have something like this 19-06-2009 Thanks ...

Incorrect Date Exception

I am trying to enter a date with with year 1900 using java into sql bt i am getting exception as : 'com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '1900-01-01 00:00:00' ' ...

Convert dateTime to unix epoch in xslt

Hi. I have a dateTime variable, and I want to convert it to a decimal value of epoch. How can this be done? I tried using: seconds-from-duration($time, xs:dateTime('1970-01-01T00:00:00')) but it just returns 0. Please advice. Thanks. ...

Rounding a MYSQL datetime to earliest 15 minute interval in milliseconds (PHP)

Hi, I'm fetching a datetime from MYSQL which looks like: 2010-08-11 11:18:28 I need to convert it into the "floor" or the earliest 15 minute interval and output in milliseconds for another function. So, this case would be: 2010-08-11 11:15:00 in milliseconds Whoops! Sorry - need to clarify - I need code that will transform it int...

"pretty print" duration in java

Hi folks, Does anyone know of a java library that can pretty print a number in milli seconds in the same way that c# does? E.g. 123456 ms as a long would be printed as 4d1h3m5s (might not be accurate , but you see hopefully what I'm getting at!!) -ace ...

PHP / MySQL - determine a series of dates based on a start date + INSERT

Hello I would like to produce a list of dates based on a user determined "start date", over a 12 week period. If a user selects today's date, I need to know each date from today over 12 weeks. Once I have these dates, I would need to insert them into a DB table. I'd like to say I've made some in-roads into how to do this, I reckon ...

convert datetime js to c#

How would I convert this from js to C#. I've looked but cant find anything useful. var endDate = new DateTime(); endDate.setDate(startDateTime.getDate() + days); endDate.setHours(endDateTime.getHours(), endDateTime.getMinutes(), endDateTime.getSeconds()); ...