datetime

How can I validate dates in Perl?

How can I validate date strings in Perl? I'd like to account for leap years and also time zones. Someone may enter dates in the following formats: 11/17/2008 11/17/2008 3pm 11/17/2008 12:01am 11/17/2008 12:01am EST 11/17/2008 12:01am CST ...

What are the best ways for maintaining server time

Many applications require server time frequently. What are the best ways for maintaining server time on client machine with minimized request to server. ...

C# serializing Class to XML where one of class properties is DateTime. How to make this property in ISO format?

Hello! I'm serializing class which contains DateTime property. public DateTime? Delivered { get; set; } After serializing Delivered node contains DateTime formatted like this: 2008-11-20T00:00:00 How can I change this property to make it look like this: 2008-11-20 00:00:00 Thanks in advance ...

Why LocalTime displays server time and not browser time?

I am probably doing something wrong -- but cant figure why. I have a DateTime field in my DB keeping a UTC time My server is in the US, and the browser is in Europe. The PageLoad Code is as follow: DateTime t = DateTime.SpecifyKind((DateTime)rdr["startTime"], DateTimeKind.Utc); label1.Text = t.ToLocalTime().ToString(); The time di...

How to convert a date in python?

I've got this: post["date"] = "2007-07-18 10:03:19" And from post["date"], I'd like to extract just "2007-07-18". I've seen some reference to strptime without being sure how to use it I'm not really familiar with python, just 1-2 scripts a year, so the solution might be obvious for a lot of you :) ...

What's the best way to find the inverse of datetime.isocalendar()?

The Python datetime.isocalendar() method returns a tuple (ISO_year, ISO_week_number, ISO_weekday) for the given datetime object. Is there a corresponding inverse function? If not, is there an easy way to compute a date given a year, week number and day of the week? ...

Checking to see if a DateTime variable has had a value assigned

Is there an easy way within C# to check to see if a DateTime instance has been assigned a value or not? ...

Setting and resetting the DATEFORMAT in SQLServer 2005

Is there a way to query the current DATEFOMRAT SQLServer 2005 is currently using with T-SQL? I have an application that reads pregenerated INSERT-statements and executes them against a database. To make the the data to be inserted culture independent I store datetime-values represented in the invariant culture (month/day/year...) . The ...

How to serialize to dateTime

Working to get DateTimes for any time zone. I'm using DateTimeOffset, and a string, and an XmlElement attribute. When I do, I get the following error: [InvalidOperationException: 'dateTime' is an invalid value for the XmlElementAttribute.DataType property. dateTime cannot be converted to System.String.] System.Xml.Serializ...

How frequent is DateTime.Now updated ? or is there a more precise API to get the current time?

I have code running in a loop and it's saving state based on the current time. Sometimes this can be just milliseconds apart, but for some reason it seems that DateTime.Now will always return values of at least 10 ms apart even if it's only 2 or 3 ms later. This presents a major problem since the state i'm saving depends on the time it w...

Select X Most Recent Non-Consecutive Days Worth of Data

Anyone got any insight as to select x number of non-consecutive days worth of data? Dates are standard sql datetime. So for example I'd like to select 5 most recent days worth of data, but there could be many days gap between records, so just selecting records from 5 days ago and more recent will not do. ...

Meaning of exception in C# app: "Not a legal OleAut date"?

Does anyone know what this means . . getting this in C# winforms applications ...

How to print date in a regular format in Python ?

I'm only just starting out with python so I'm still pretty clueless. What I'm trying to do is to get the date from the pc and adding it to a list. This is my code: import datetime today = datetime.date.today() print today This prints: 2008-11-22 which is exactly what I want BUT....I have a list I'm appending this to and then suddenly ...

are there any commands that are usually used for comparing time in bash shell script?

this was for an old computer class project which I am over with and now am wondering if there was a better way of doing things . we used to program an appointment.sh program where I solved the comparing time using an algorithm which converts time to a certain number you can compare today and tomorrow and of course what happens is it c...

Localization of date-time using custom patterns.

I am working on localization for an app where custom patterns are used to format the date-time. one example is: dd-MM HH:mm I need to get localized versions of this custom format for dates, so that I get the date using numbers, and the time, basically using the local order (dd MM or MM dd) and the local seperator for both date and tim...

Using SQL Server 2008 and SQL Server 2005 and date time

I've built a entity framework model against a 2008 database. All works ok against the 2008 database. When I try to update the entity on a 2005 database I get this error. The version of SQL Server in use does not support datatype 'datetime2 I specifically did not use any 2008 features when I built the database. I can't find any ref...

String.Format (format,date) is ignoring format

Not sure what's going on here. I have a DateTime object, and when I try: String.Format( "{0:dd/MM/yyyy}", _date) the value returned is: "24-05-1967" What I want is "24/05/1967" Can anyone explain why my format string is being ignored? A bit more background: This is a web app which started out life as .net 1.1, and I'm in the ...

how to convert server time to local time

I have a problem with time My server is in the USA and I'm in Denmark (Europa) and I would like to have my site show the time in my local time. How can I do that? I try this Datetime localtime = DateTimeOffset.Now.ToOffset(new TimeSpan(1,0,0)).DateTime; and it works, but it will only work when I'm in GMT+1 / UTC+1 and not when I'm...

Ruby on Rails and Active Record standalone scripts disagree on database values for :timestamps

I posted a question earlier today when I'd not zeroed in quite so far on the problem. I'll be able to be more concise here. I'm running RoR 2.1.2, on Windows, with MySQL. The SQL server's native time zone is UTC. My local timezone is Pacific (-0800) I have a model with a :timestamp type column which I can do things like this with: ...

Date/time conversion: string representation to time_t

What's the best way to convert a date string, formatted as "MM-DD-YY HH:MM:SS", to a time_t value in either C or C++? ...