datetime

Excel function to determine the last Friday in a month

I'm looking for an Excel function to return the last Friday in a month for a given date. ie: Any date in the month as input will give the date of the last Friday as output. 14-July-09 should give 31-July-09 7-March-05 should give 35-March-09 ...

How to String.Format the day of the month in c#?

DateTime's formatting has some overlap between it'a standard date and time formatting strings and some of it's custom format specifier by them selves. As a result, when I evalate this expression: string.Format(">{0:d}< >{0: d}<", DateTime.Now) and get this result: >8/3/2009< > 3< My question is: How do I get String.Format to out...

How do I pass a datetime value as a URI parameter in asp.net mvc?

I need to have an action parameter that has a datetime value? Is there a standard way to do this? I need to have something like: mysite/Controller/Action/21-9-2009 10:20 but I'm only succeeding indoing it with something like: mysite/Controller/Action/200909211020 and writing a custome function to deal with this format. Again, lo...

PHP strtotime() outputs nothing

Here is my PHP code: echo '<br />1. '.$w_time_no; echo '<br />2. '.strtotime($w_time_no); echo '<br />3. '.date('G:i', strtotime($w_time_no)); That's what I get: 1. 0000-00-00 22:00:00 2. 3. 2:00 Why strtotime() outputs nothing by itself? Is there something wrong with server settings? Server: Apache/2.2.11 (Win32), PHP 5.2.10, MySQ...

Javascript serialization of DateTime in asp.net is not giving a javascript date object?

When I parse a DateTime to json in .Net it returns a string (i.e. "\/Date(1249335194272)\/"). How do I make it return a js Date object constructor not wrap in a string? // js server code var dteNow = <%= jsonDateNow %>; // js rendered code var dteNow = "\/Date(1249335477787)\/"; // C# using System; using System.Collections.Generic; ...

What is the correct way to handle timezones in datetimes input from a string in Qt

I'm using Qt to parse an XML file which contains timestamps in UTC. Within the program, of course, I'd like them to change to local time. In the XML file, the timestamps look like this: "2009-07-30T00:32:00Z". Unfortunately, when using the QDateTime::fromString() method, these timestamps are interpreted as being in the local timezone. T...

Calculate the start and end date of a week given the week number and year in C# (based on the ISO specification)

I need to generate a report that shows the 52 weeks of a year (or 53 weeks as some years have) and their start and end dates. There is an ISO spec to do this but seems awfully complicated! Im hoping someone knows of a way to do it in C# or Visual Basic (its actually for Visual Basic 6 but I will try port it across) ...

How can I determine the column type represented by a MySql .Net Connector's MySqlDateTime structure?

DataColumn.DataType returns FullName = "MySql.Data.Types.MySqlDateTime" regardless of the type of the column it represents, if it is either DATE, TIME, or DATETIME. Clearly I can query the information_schema.columns table, though I'm hoping that the connector library stores this detail somewhere that I just can't find in the documentati...

How to read the XSD datetime format in PHP ?

Is there a function, class, or extension in PHP that can handle the XSD datetime format? It's a standard XML date & time format, that looks like this: <date>2008-02-28T07:56:35.263</date> I know I can read it with a regular expression, if no solution is given, I'll default to that. Thanks! PS: Solved, look at the answers. ...

PHP's strtotime() in Java?

I'm looking for an easy way to generate a MySQL DATETIME from any type of time input a user may enter. PHP makes it easy with its strtotime() function that can do: strtotime(’2004-02-12T15:19:21+00:00′); strtotime(’Thu, 21 Dec 2000 16:01:07 +0200′); strtotime(’Monday, January 1st’); strtotime(’tomorrow’); strtotime(’-1 week 2 days 4...

why is my date validator not working?

Hi, I'm trying to validate a date entered into text boxes like so using a custom validator: string CombinedDate = String.Format("{0}-{1}-{2}", txtDay.Text, txtMonth.Text, txtYear.Text); if (DateTime.TryParseExact(CombinedDate, "dd-MM-YYYY", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out date)) { args.IsValid = true; } e...

Why does an hour get added on to java.util.Date for dates before Nov 1 1971?

The following code appears to demonstrate a bug in java.util.Date whereby an hour gets added on if the local clock is set to GMT with DST adjustment on and the time is before Nov 1 1971. My first assumption is always that I've got it wrong. Can anyone see what's wrong (or is this really a Java bug)? What's significant about Nov 1 1971? ...

How to tag an XML DateTime attribute with XmlDateTimeSerializationMode?

Is there any way I can define how a DateTime should be serialized/deserialized using something similar to the XmlAttribute tag? In the past I would make the field a string and then do something like this in the constructor: this.DateField = XmlConvert.ToString(passedObject.Date, XmlDateTimeSerializationMode.Utc); However, I'd like to...

Why does Zend_Date only take timezones into account when parsing?

I'm working with Zend 1.8. I've set the default timezone to Europe/Helsinki, and I'm parsing a string that looks like this: 2009-08-06 with a statement like this: new Zend_Date($dateStr, 'YYYY-MM-dd'); It produces a date like this: object(Zend_Date)#53 (8) { ["_locale:private"]=> string(5) "en_US" ["_fractional:private"]=> ...

Convert time in PHP or Javascript?

I am curious which is the best way to convert time like this 2008-04-23 into 1 year and 3 days ago I currently do this in PHP but I am finding a lot of sites do it in javascript, including Stackoverflow What do you think is the best way, it seems offloading it to the browser with javascript would just slow your app down, yes the big bo...

jQuery DateTime Picker

I've been looking around for a decent jQuery plugin that can handle both dates and times. The core UI DatePicker is great, but unfortunately I need to be able to take time in as well. I've found a few hacks for the DatePicker to work with times, but they all seem pretty inelegant and google isn't turning up anything nice. Do any of yo...

How I can set a date string from twitter to a NSDATE

The date you get back from twitter is in this format Fri Aug 07 12:40:04 +0000 2009. I am able to assign the value to a NSDate without issue. However, when I attempt to use NSDateFormatter, I get a nil returned to me. What am I missing? NSDate *createdAt = [messageData objectForKey:@"created_at"]; NSDateFormatter *format = [[NSDateFor...

Strange behavior from setInterval()

I'm trying to do a very basic date-difference calculation with javascript, but am getting mixed behavior from setInterval(). This updates constantly: var init = setInterval(function(){ document.getElementById("txt").innerHTML = new Date(); }, 1000); But this only updates once: var init = setInterval(function(){ var today = new D...

Sending the current date via ajax to my .net handler, how to pass a safe date?

Hi, I need to pass a date, that will be generated via javascript to a asp.net http handler that is services in ajax requests. On the .net side, I will take the date passed in a cast it to DateTime. The date has to have: yyyy, mm, dd, and minutes and seconds. How can I format a date in javascript to this format? Using jquery ...

What is your favorite date and time format in a file name?

This is a somewhat subjective question, and not very important in the big scheme of things, but something that yet annoys me regularly. There seems to be no self-evident way to put a timestamp in a file name. Objective issue is that timestamps in file names should be sortable. But .NET sortable date formats like "s" ("yyyy-MM-ddTHH:mm:...