date

How do you format date and time in Android?

How do you format correctly according to the device configuration a date and time when having year, month, day, hour and minute? ...

Verify a date in JavaScript

I need to do user validation of a date field, it should be in the format yyyyMMdd and should not be more than one year in the future. How would I go about doing this? Currently I only have a crude regexp which is insufficient. function VerifyDate(source, args) { var regexp = /^([1-2]{1}[0-9]{1})\d{2}([0][1-9]|[1][0-2])([0][1-9]|[1-2...

Whats the Most efficient way to Check if a Date is between Recurrence of a Span ?

What's the most efficient way to check if a date falls between a repetition of a span of time using the c# date class. E.g., you have the span 01/01/2009 1:00:00 am to 01/06/2009 5:00pm which repeats every x number of years, months, or weeks, etc. And I want to check if variable date x falls between any recurrence I read Martin Fowler...

How do you set the time and only the time in a calendar in Java?

Having the hours and minutes, is there any easier or better way to set it into a Calendar object than: calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), hour, minute); ...

Why was "new Date(int year, int month, int day)" deprecated?

My application I've recently inherited is FULL of deprecation warnings about the constructor: Date d = new Date(int year, int month, int day) Does anyone know or can point to a reason why something as simple as this was "replaced" with something like this: Date d = new Date(); Calendar cal = GregorianCalendar.getInstance(); cal.set(1...

What is the easiest algorithm to find the day of week of day zero of a given year?

I am trying to figure out what the day of the week of day zero (January 1st) of a given year. So far I have looked at the Wikipedia page 'Calculating the day of the week' but I was wondering if there is an easiest algorithm if you're just trying to find day zero. ...

Work out the percentage of the day that has elapsed

Slightly strange question, but hopefully someone can help. In essence, if the time was 12pm the the elapsed percentage would be 50%, 6am would be 25% and 16pm would be 75%. Given the current time, how could you work out the amount of day that already passed? ...

How do I handle date and time in different time zone ?

I'm developing an international software that act as a simple project management software and I'm facing a problem. This problem is about date/hour and time zone. When a message is sent from one time zone to another time zone I can store the UTC (GMT) time in my database and then have it displayed differently according to the user's time...

Whats the best java date recurrence pattern calculator

Anyone know of a (reliable) date recurrence calculator, we're trying to implement something in our app which would allow a schedule to be created, similar to those for recurring meetings in Outlook. We have tried chronos but discovered some cases where it breaks down, I'd really appreciate knowing if anyone has successfully used any of t...

Compare 2 dates with JavaScript

Hi, can some one suggest a way to compare values of 2 dates greater then, less then and not in the passed using javascript. They values will be coming from text boxes Thanks ...

Java: how do I check if a Date is within a certain range?

I have a series of ranges with start dates and end dates. I want to check to see if a date is within that range. Date.before() and Date.after() seem to be a little awkward to use. What I really need is something like this pseudocode: boolean isWithinRange(Date testDate) { return testDate >= startDate && testDate <= endDate; } Not...

how to get the day from a particular date using javascript.

hi there, i am new to javascript. my requirement is .. i want to popup a message on particular days(like sunday,monday..) all through when a date is selected. i tried getday() function but it didnot work. please suggest me. i am tired of searching google ...

Inserting Dates into HTML Table Cells

I am wanting to have a series of dates (mainly Month, Day, Year) displayed within a vertical arrangement of table cells on a web page. The first date needs to be the current date minus one day, with the next date in the sequence be the current date, The remaining dates need to incrementally be one day in future out to 16 days. Can som...

How do I join the most recent row in one table to another table?

I have data that looks like this: entities id name 1 Apple 2 Orange 3 Banana Periodically, a process will run and give a score to each entity. The process generates the data and adds it to a scores table like so: scores id entity_id score date_added 1 1 10 1/2/09 2 2 ...

How can I convert a date value in UTC format to a date object in Javascript?

I've been trying to convert a UTC value in a string into a more readable format. To do that, I'm trying to parse the date using the Javascript Date.parse method. That however does not work on the input (eg:"2007-09-21T14:15:34.058-07:00") that i have. The end goal is to output a date string like "January 30th, 2008 @ 2:15PM". Any ideas?...

Javascript Date: next month

I've been using Javascript's Date for a project, but noticed today that my code that previously worked is no longer working correctly. Instead of producing Feb as expected, the code below produces March. My code looks something like this: current = new Date(); current.setMonth(current.getMonth()+1); //If today is Jan, expect it to be...

how to get the date of last week's (tuesday or any other day) in php?

I think its possible but i cant come up with the right algorithm for it. What i wanted to do was: If today is monday feb 2 2009, how would i know the date of last week's tuesday? Using that same code 2 days after, i would find the same date of last week's tuesday with the current date being wednesday, feb 4 2009. ...

Converting date between DD/MM/YYYY and YYYY-MM-DD?

Hello Using a Python script, I need to read a CVS file where dates are formated as DD/MM/YYYY, and convert them to YYYY-MM-DD before saving this into a SQLite database. This almost works, but fails because I don't provide time: from datetime import datetime lastconnection = datetime.strptime("21/12/2008", "%Y-%m-%d") #ValueError: ti...

Best way to store old dates in SQL Server

What is the best/most efficient way to store old dates (pre-1753) in SQL Server 2005? I am not concerned with storing times - just dates. SQL Server's datetime data type can only hold dates back to January 1, 1753. The MSDN documentation states that there are date and datetime2 data types, but SQL Server Management Studio does not seem t...

C# - How do I sort a DataTable by date.

I have a datatable that has a date column, but I am stumped as to how to sort it by that column. Any suggestions? ...