datetime

How do you get a timestamp in JavaScript?

Something similar to Unix's timestamp, that is a single number that represents the current time and date. Either as a number or a string. ...

VC++ MFC edit box sorting

How do I sort the date and time in decending order in edit box? ...

DateTime "null" value

I've been searching a lot but couldn't find a solution. How do you deal with a DateTime that should be able to contain an uninitialized value (equivalent to null)? I have a class which might have a DateTime property value set or not. I was thinking of initializing the property holder to DateTime.MinValue, which then could easily be check...

Converting between oracle.sql.TIMESTAMPTZ and standard JDBC classes for DbUnit

I'm running Oracle 10g and have columns with Type_Name TIMESTAMP(6) WITH TIME ZONE When inflated into java classes they come out as oracle.sql.TIMESTAMPTZ But DbUnit can't handle converting Oracle specific classes to Strings for writing to XML. I'm wondering if there's any easy way for me to convert (say, in my SELECT statement so...

jQuery datepicker - Restrict dates from server side (ASP.NET)

I have a jQuery datepicker that I want to restrict non work days - weekends, public holidays etc. I have seen examples on how to do this from the client side (javascript), but is there a way to restrict the dates from server side ASP.NET code? I figure you could do using Page.RegisterClientScriptBlock, but was wondering is there a neate...

Should the timezone be a constant or a variable?

I have a few places in the code where I need to use the TimeZone. I can get the timezone name using DateTime::TimeZone. Is it reasonable to put the timezone name in a constant? Or should it be in a variable? ...

RFC 1123 Date Representation in Python?

Is there a fairly easy way to convert a datetime object into an RFC 1123 (HTTP/1.1) date/time string, i.e. a string with the format Sun, 06 Nov 1994 08:49:37 GMT Using strftime does not work, since the strings are locale-dependant. Do I have to build the string by hand? ...

Parsing different date formats from feedparser in python?

I'm trying to get the dates from entries in two different RSS feeds through feedparser. Here is what I'm doing: import feedparser as fp reddit = fp.parse("http://www.reddit.com/.rss") cc = fp.parse("http://contentconsumer.com/feed") print reddit.entries[0].date print cc.entries[0].date And here's how they come out: 2008-10-21T22:23:...

Displaying Time Zones in WPF/C#. Discover Daylight Savings Time Offset

I am having trouble understanding how the System Registry can help me convert a DateTime object into the a corresponding TimeZone. I have an example that I've been trying to reverse engineer but I just can't follow the one critical step in which the UTCtime is offset depending on Daylight Savings Time. I am using .NET 3.5 (thank god) b...

What is the preferred format to store date/times in a SQL Server database when PHP is your primary language?

I am planning a PHP application that needs to store date/times in an MSSQL database. (For the curious, it is a calendar application.) What is the preferred format to store this information? MSSQL has its own datetime data type, which works well in the database itself and is very readable. However, there aren't any MSSQL functions to tra...

how to uppercase date and month first letter of ToLongDateString() result in es-mx Culture ?

currently i obtain the below result from the following C# line of code when in es-MX Culture Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-mx"); <span><%=DateTime.Now.ToLongDateString()%></span> miércoles, 22 de octubre de 2008 i would like to obtain the ...

Date time format from string?

How do I convert a string to DateTime format? For example, if I had a string like: "24/10/2008" How do I get that into DateTime format ? ...

Subtract n hours from a DateTime in Ruby

Hello there, I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range). DateTime has two methods "-" and "<<" to subtract day and month, but not hour. (API). Any suggestions how I can do that? ...

How do you do end-of-week rounding on a date field in C# (without using LINQ)?

I have a weird date rounding problem that hopefully someone can solve. My client uses a work week that runs from Monday through Sunday. Sunday's date is considered the end of the week, and is used to identify all records entered in a particular week (so anything entered last week would have a WEEKDATE value of '10/26/2008', which is Su...

Parse DateTime with timezone of form PST/CEST/UTC/etc

I'm trying to parse an international datetime string similar to: 24-okt-08 21:09:06 CEST So far I've got something like: CultureInfo culture = CultureInfo.CreateSpecificCulture("nl-BE"); DateTime dt = DateTime.ParseExact("24-okt-08 21:09:06 CEST", "dd-MMM-yy HH:mm:ss ...", culture); The problem is what should I use for the '......

Environment.TickCount vs DateTime.Now

Is it ever OK to use Environment.TickCount to calculate time spans? int start = Environment.TickCount; // Do stuff int duration = Environment.TickCount - start; Console.WriteLine("That took " + duration " ms"); Because TickCount is signed and will rollover after 25 days (it takes 50 days to hit all 32 bits, but you have to scrap the s...

Best way to create a Midnight DateTime in C#

I need to create a midnight DateTime I've just done this: DateTime endTime = DateTime.Now; endTime.Subtract(endTime.TimeOfDay); Haven't test it yet, I'm assuming it works but is there a better/cleaner way? ...

Creating a DateTime in a specific Time Zone in c# fx 3.5

I'm trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected. In the test I need to be able to create DateTime objects in a none local time zone to ensure that people running the test can do so successfully irrespective of where they are located. Fro...

Data timeline performance in Sql Server

I have a table with three columns: user varchar, status varchar , rep int status and rep get updated often and one of the requirements is: Given a datetime value view status and rep values, for each user, at the given date. I can add an updated_at datetime column to the table and insert new rows whith the same user instead of update ...

How do I prevent DateTime from including zone offset in SOAP xsd:dateTime element?

I have this in some WSDL: <element name="startDate" type="xsd:dateTime"/> <element name="endDate" type="xsd:dateTime"/> Which results in the following text in the SOAP envelope: <startDate>2008-10-29T12:01:05</endDate> <endDate>2008-10-29T12:38:59.65625-04:00</endDate> Only some times have the milliseconds and zone offset. This cau...