date

Java - How to get current year?

I want to know the current Date and Time. The code Calendar.getInstance(); represents a date and time of the system on which the program is running and the system date can be wrong. So Is there any way by which I can get correct current date and time irrespective of the date and time of the system on which program is running? ...

Django aggregation on a date range

Hi all, I have been lurking and learning in here for a while. Now i have a problem that somehow i cannot see an easy solution. In order to learn django i am bulding an app that basically keeps track of booked items. What I would like to do is to show how many days per month for a selected year one item has been booked. i have the follow...

date_sub is not working

As my server is not upgreaded to php 5.3 (it is in PHP Version 5.2.11) date_sub is not working. here is the code: $date = date_create(date('Y-m-d')); date_sub($date, date_interval_create_from_date_string('60 days')); $date1= date_format($date, 'Y-m-d'); but its ok in my localhost(which is in 5.3), but no...

Check a Date is between two dates in Java

Hello guys, One thing I want to know is how to calculate what date will it be 10 days from today. Second thing is to check if one Date is between two other Dates. For example, let's say I have an app that shows what events I need to do in the next 10 days (planner). Now how can I see if the date I assigned to an event is between today...

compare time using date command

Say I want a certain block of bash script execute only if it is between 8 am (8:00) and 5 pm (17:00), and do nothing otherwise. The script is running continuously So far I am using date command. How to use it compare it current time within the range? Thanks ...

jquery date validation on multiple fields

I am attempting to use jquery to validate a date that is broken up into MM DD YYYY fields. <form name="dateform" id="dateform"> <input type="text" name="month"/> <input type="text" name="day"/> <input type="text" name="year"/> </form> I can only find examples that use a single field, which is not what I want. <form name="dateform" i...

Why were most java.util.Date methods deprecated?

When you look at the javadoc of the java.util.Date class, most of the methods are deprecated. Why was this done? ...

JPA Date Arithmetic?

Is it possible to perform date arithmetic using JPA/Hibernate? For example, I have an entity with a java.util.Date field indicating when the row was created. Is it possible to perform a query using JPQL and include date arithmetic on that field? For example, can I perform a COUNT(*) of rows and then GROUP BY the month in that field? ...

NSDateFormatter return nil on 2 different input which in same format!?

Hi all! I am newbie of objective-c and i got this crazy problem… for low precision test case: dateString = @"2010-05-25 11:05:21", conversion success. dateString = @"2010-03-01 15:54:36", conversion fail. for high precision test case: dateString = @"2010-05-25 11:05:21.937113", conversion success. dateString = @"2010...

javascript date.utc problem

I'm trying to compare 2 dates using javascript. 1 at the end of the month and 1 at the beginning. I need to compare these 2 dates in seconds so I'm using the Date.UTC javascript function. Here's the code: var d = Date.UTC(2010,5,31,23,59,59); document.write(d); var d2 = Date.UTC(2010,6,1,12,20,11); document.write(d2); The output fo...

The Date type and the Android database

I understand that SQLite stores dates as long integers. When I read rows using the standard method (i.e. using the query() method that reads data into a cursor), the result is a date string that includes the time: 2010-05-25 19:52:04 If I want a different format, I have to parse the string back into a date - possible, but a bit backwa...

Struggling with how to compare hours with different time zones in Java?

Hi! I have 2 date object in the database that represent the company's working hours. I only need the hours but since I have to save date. it appears like this: Date companyWorkStartHour; Date companyWorkEndHour; start hours: 12-12-2001-13:00:00 finish hours: 12-12-2001-18:00:00 I have the timezone of the company and of the user. (...

Date comparison in Oracle database

I have two variable TO_DATE and FROM_DATE. My table has two fields DOJ and DOL. I want to select all the records whose DOJ < TO_DATE and DOL > FROM_DATE. How can i write an SQL query in for this?? ...

get days of a month in JS/Prototype

Hi, I´m looking for a function/prototype extension, which returns all days of a given month. I couldn't find anything helpful at the standard date() functions (http://www.w3schools.com/jsref/jsref_obj_date.asp). i.e.: getDays(2010-05) // returns something like: { day:'Saturday', date:'2010-01-05' }, { day:'Sunday', date:'2010-...

PHP How to find the time elapsed since a date time?

How to find the time elapsed since a date time stamp like '2010-04-28 17:25:43', final out put text should be like 'xx Minutes Ago'/'xx Days Ago' ...

Organising dates in PHP

Hi All, Im wanting to organize a series of dates in the following format. As a bit of context, the dates are the dates of upcoming events that can be added by my users. The format: January 2011 date - event date - event date - event February 2011 date - event date - event date - event with all events in a given month, arranged ...

Basic date/time manipulation in NHiberate query

I'm trying to restrict my NHibernate query with some basic date/time manipulation. More specifically, I want to execute the following statement (pseudo-SQL): select * from article where created_on + lifespan >= sysdate with: created_on is mapped to a property of type DateTime. lifespan is mapped to a property of type TimeSpan. sysda...

smaller date regex

I have a regex used to validate dates: ^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$ Works really well, but I am...

Pass Date object from javascript to asp.net mvc controller

Hi, I have a Date variable in client side and I want to pass the Date variable to my controller at server side. I have passed as a normal field and the date is defaulting to 01-01-0001 12:00:00 AM. help me to convert the date field with the right format. ...

AS3 get closest date to today

Hi, I have a XML file with a few concert dates. In my flash/AS3 file, I would like to show only the up coming event, relative to current date. Like this: Event 01: 30-05-2010 Event 02: 02-06-2010 Event 03: 05-06-2010 Today is 28-05-2010, so I need to list Event 01. On 01-06-2010 I need to list Event 02. I have the basic AS3 code f...