datetime

Pretty printing of DateTime values in C#

I'm hoping that someone has found a way of doing this already or that there is a library already in existence. It's one of those things that would be nice but is in no way necessary for the time being. The functionality I'm looking for is something like datejs in reverse. Thanks, Simon. ...

Getting Dates between a range of dates

Hi All, I need to get all the dates present in the date range using SQL Server 2005 ...

Has the daylight savings rule change invalidated the C runtime library?

Some time ago I put together a time based library that could be used for working out relative times within a year for someone. I noted at the time, that it did the one hour shift in both directions for daylight savings. It just occurred to me that Congress changed the daylight savings time rules. I don't recall seeing any information...

MOSS 2007: SPListItem.GetFormattedValue for DateTime fields has a bug?

SPListItem.GetFormattedValue seems to have a strange behavior for DateTime fields. It retrieves the DateTime value through SPListItem's indexer which according to this MSDN article returns local time. Here's a snippet from Reflector public string GetFormattedValue(string fieldName) { SPField field = this.Fields.GetField(fieldName); ...

How to set the date/time in C#

How do I set the date/time of the computer in C#? ...

Convert to/from DateTime and Time in Ruby

How do you convert between a DateTime and a Time object in Ruby? ...

Parsing time without date in a TextBox

I'm working on a time sheet application, where I'd like the user to be able to enter times in TextBoxes, e.g.: 8 a or 8:00 a or the like, just like you can in Excel. Now if you enter a date in a TextBox and then use DateTime.TryParse, you can enter it in several formats (Jan 31, 2007; 1/31/2007; 31/1/2007; January 31, 2007; etc.) and .N...

Asp.net Date Binding Issue with Nulls

I have a nullable date in my database. I am connecting to it with a LinqDataSource, and binding with a FormView. It allows you to place dates fine, but if you remove the date I need it to insert the null value to the db. It is instead throwing an exception. <asp:TextBox ID="TxtStartDate" runat="server" Text='<%# Bin...

How do I parse and convert DateTime’s to the RFC 822 date-time format?

How do I convert a DateTime structure to its equivalent RFC 822 date-time formatted string representation and parse this string representation back to a DateTime structure? The RFC-822 date-time format is used in a number of specifications such as the RSS Syndication Format. ...

Calculating date for a day of the week

Given a week-day (1-7), how can I calculate what that week-day's last date was? Example: Today is Wednesday, 2008/11/12, and I want to know what last Friday's date was. ...

Anyone know of a free date and *time* ASP.NET custom control

Every time I have to build a form with a DateTime field I try to find a decent free custom control - I always fail. I cannot figure out why it isn't built in the .NET but let's forget about for a minute and concentrate on my question :D Anyone got one? ...

calculate seconds-to-date for pre-epoch date/times using MS VS2003

Hi all, I have this routine that calculates the seconds-to-date for a struct tm. On Linux my implementation using mktime works fine, but mktime on windows VS2003/.NET 1.1 returns -1 for pre-epoch datetimes. How do I calculate meaningful time_t values (i.e. value + secondsToEpoch == secondsToDatetime ) from a for pre-epoch dates...

Ruby on Rails: Is it possible to request the current time from the SQL server?

In a previous question about overriding Time.now, I was working toward a solution of faking clock synchronization across all machines connecting to a given database. Overriding Time.now seemed the best way for the approach I was taking, however: It appears as though I could get the result I was after via a much simpler line. If I can ...

Java System.currentTimeMillis() equivalent in C#

What is the equivalent of Java's System.currentTimeMillis() in C#? ...

.NET Store DateTime in SQL in different timezone and different locale

What is the best way to store DateTime in SQL for different timezones and different locales There a few questions/answers about timezones, but none is addressing the locale problems. DateTime.ToUniversalTime is locale specific, and I need it locale independent. For example: DateTime.Now.ToUniversalTime.ToString() In US locale...

Decimal DateTime formatter in Java or Joda

I'm writing a file that requires dates to be in decimal format: 2007-04-24T13:18:09 becomes 39196.554270833331000 Does anyone have a time formatter that will do this (Decimal time is what VB/Office, etc. use)? Basic code goes like follows: final DateTime date = new DateTime(2007, 04, 24, 13, 18, 9, 0, DateTimeZone.UTC); double ...

Getting notified when the datetime changes in c#

Recently I was trying to make a calendar application that will display the current year-month-date to the user. The problem is, if the user is gonna keep my application running even for the next day, how do I get notified ?? How shall I change the date displayed ? I don't wanna poll the current date to update it. Is this possible in c#. ...

How can I parse relative dates with Perl?

I'd love to know if there is a module to parse "human formatted" dates in Perl. I mean things like "tomorrow", "Tuesday", "next week", "1 hour ago". My research with CPAN suggest that there is no such module, so how would you go about creating one? NLP is way over the top for this. ...

.NET DateTime.Now returns incorrect time when time zone is changed

This problem occurred during daylight saving time change. After the change occurred, we've noticed that our server application started writing into the log incorrect time - one hour ahead which means that .NET caches time zone offset. We had to restart our application to resolve this problem. I wrote a simple application to reproduce thi...

C#: How do you get the current time of day?

C#: How do you get the current time (not date AND time)? Example: 5:42:12 PM ...