date

PHP convert one date into another date format

Hi, Is there a very simple way in PHP to convert one date format into another date format? I have this: $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); // returns (bool)false $new_date = date('Y-m-d H:i:s', $middle); // returns 1970-01-01 00:00:00 But I'd of course like it to r...

Converting DayOfWeek enum to a string repesenting the day

I was wondering if there was a way to directly convert the integer DayOfWeek returns into a string representing the day like Monday, Tuesday etc. Sample code: MessageBox.Show(Date.Today.DayOfWeek) This will return 6 (as of today). Is there a way to directly convert this into Saturday, for example? I don't really care what it really c...

Are integer queries on MySQL DATE or TIME columns slow?

Is it more efficient for me to store dates as INTs and convert to and fro a string representation such as "2010-01-30" or is it alright to store dates as DATE when needing to perform very frequent integer queries such as WHERE Date < 20100130... Are dates internally stored as strings or integers? ...

Date picker doesnt allow edit and no null accepting

Hi Friends, Iam new to this forums. by the suggestion of my friend i came to know that this forum is very very good and we get a very good responses. iam new to .NET 3.5 , WPF, infragistics and MVVM. I have two calender controls and button control ( when clicking the button user see a list of events between the date range. We follow M...

Error comparing dates in SQL query

Within a ASP.NET/C# class I am trying to run a query where I compare dates: select * from table1 CreatedDate >='DATEADD(d,-500,GETDATE())'; Basically I am trying to select rows from the the last 500 days. The problem is I am getting the following error: Syntax error converting datetime from character string. An example of the Creat...

Is there any difference between DATE_SUB() and using arithmetic operators for datetime calculation?

After I have seen a lot of questions here using the DATE_SUB() or DATE_ADD() functions instead of the arithmetic operators + or -, I was wondering if there was any difference: Quote from the MySQL-manual: Date arithmetic also can be performed using INTERVAL together with the + or - operator: date + INTERVAL expr unit date - INTER...

Is there some functionality in Cocoa to display time intervals in natural language?

What I am searching for is a Cocoa (or third party) class that can display time intervals in natural language, e.g.: 10 seconds ago 1 hour ago 2 days ago Do you know anything that could help me to achieve this task without writing it by myself and melting in if-else hell? ...

javascript dates in IE, NAN - firefox & chrome ok

I'm trying to build a little calendar in javascript, and I've got my dates working great in Firefox and chrome, but in IE, the date functions are returning NAN. Here is the function function buildWeek(dateText){ alert(dateText); var headerDates=''; var newDate = new Date(dateText); var...

Calculate date difference having a large range with PHP

Hi, I need to calculate the number of decades between 2 dates possible spanning form 1708 until today - the limitations are as far as I can gather are 1970/1901 within PHP native functions. Can anyone advise? Thanks! ...

Properly formatted MySQL date insert statement returns all 0's

I've created a PHP script that parses an HTML page, creates a MySQL query, and inserts the parsed data into a MySQL table. Everything works fine, except for one thing : the date field. When PHP runs the MySQL statement, the dates in the table read 0000-00-00 . If I echo the MySQL query, it results in the following : INSERT INTO dispatc...

How to create a datetime validator in a Zend Framework form?

By default a Zend Framework date validator uses the date format yyyy-MM-dd: $dateValidator = new Zend_Validate_Date(); But I want to add hour and minute validation. In other words, I want to require the user to enter the hour and minute. But the following does not work: $dateValidator = new Zend_Validate_Date('yyyy-MM-dd hh:ii'); I...

Find date for same day of the week last year?

OK so for example, today is Tuesday, Feb 02. Well the equivalent "Tuesday" from last year was on Feb 03. How can I find this out programmatically? Thanks!! ...

How to set a BCE year using GregorianCalendar

I have an assignment that converts dates from one calendar system to another. The documentation for GregorianCalendar seems to suggest that you can use dates with BCE years, but I have no idea how. If I simply make the year negative, i.e. GregorianCalendar cal = new GregorianCalendar(-20, 1, 2, 3, 0, 0); System.out.println(cal.getT...

How do I get GWT DateTimeFormat to display using the server TimeZone, rather than the client's?

I am trying to display a (java.util.)Date client-side, and it keeps using the browser's timezone, resulting in a different date visible depending on where you view the page. How do I get the Formatter (DateTimeFormat) to display the date using the server's timezone rather than the user? Thanks ...

How to subtract a month from Date object?

How do I subtract a month from a date object in VB.NET? I have tried: Today.AddMonths(-1) However, given that Today is 01-Jan-2010, the result I get is 01-Dec-2010. The answer I want is 01-Dec-2009. Is there a convenient way of doing this within the .NET framework? ...

Parse RSS pubDate to Date object in JavaScript

How would I do this? Tue, 2 Feb 2010 19:34:21 Etc/GMT ...

PHP Convert timestamp to months and days

How can I convert a timestamp difference between 2 dates ( $diff = abs(strtotime($date2) - strtotime($date1)); ) to months and days quantity (ouput: $res = 4.05 -> 4 months and 5 days)? Thanks. ...

Round date to 10 minutes interval

I have a DATE column that I want to round to the next-lower 10 minute interval in a query (see example below). I managed to do it by truncating the seconds and then subtracting the last digit of minutes. WITH test_data AS ( SELECT TO_DATE('2010-01-01 10:00:00', 'YYYY-MM-DD HH24:MI:SS') d FROM dual UNION SELECT TO_DATE('2010-0...

unix time in mysql

when they say "we will use unix time", does that mean i should create a column like this ? date DATE or date TIME or date DATETIME ? ...

PHP date function accept null or empty string and return value

it's amzing when i send a null value in date() as a second parameter then it returns some time? how to remove this thing. i want that if a string is null or empty then doesn't do anything $x=strtotime(); var_dump($x); var_dump($x==NULL); echo date('H:i',$x); display Warning: strtotime() expects at least 1 parameter,...