Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Date compare



  Convert time to Unix time

Unix time is defined as the number of seconds that have elapsed since midnight Coordinated Universal Time (UTC), 1 January 1970,not counting leap seconds. It is used widely in Unix-like and many other operating systems and file formats. It is neither a linear representation of time nor a true representation of UTC. Unix time may be checked on some Unix systems by typing date +%s on the command line. Sometimes it's a bit difficult to compare times stored in different applications or systems with ...

   UNIX time, Oracle DATE, conversion, timestamp     2013-01-19 09:04:17

  Date interval add and sub prior to PHP 5.3

After PHP 5.3, we can use DateInterval object or date_interval_create_from_date_string() function to add or subtract days,weeks,months or years to or from a DateObject.But prior to PHP 5.3,we cannot do this. If we want to achieve the same effect. We need to use some skills. Here is one:We can use strtotime() function to achieve this. For example:$date=date('Y-m-d',time());$datestamp=strtotime(date('Y-m-d',strtotime($date)).' +1 day'); $datestamp=strtotime(date('Y-m-d',strtotime($date)).' +1...

   PHP,DateInterval,Class,PHP 5.3,PHP 5.2     2011-10-21 10:50:10

  The confusing strtotime() function in PHP

Frequently PHP programmers get confused of the use of i month, -1 month, next month in strtotime() function. and hence it leaves some impression to programmer that this function is not that reliable. Let's take one example of strtotime call with -1 month and see why it leaves this impression. date("Y-m-d",strtotime("-1 month"))  // Assume today is 2018-07-31 What's the output of above call? The answer is 2018-07-01. Why not 2018-06-30? So people get confused. It appears that this is ...

   PHP,STRTOTIME,FIRST DAY OF,-1 MONTH     2018-08-04 05:49:32

  String intern in Java

In Java, == is used to compare whether two objects have the same memory location, equals() is usually used to compare whether two objects have the same time and the same state.  When comparing two strings, normally we just want to know whether they have same content, so we can choose equals(). But since String comparison is so frequently needed, Java has worked on the String class to make == workable when comparing two String literals. The String class maintains a pool of emp...

   JAVA,STRING     2016-04-10 03:35:25

  Why cannot compare double values directly for equality?

A question in PHP: Get some value from the database and use floatval() to convert it to floatint point value, then compare it with another value which is also converted to floating point value with floatval(). These two values are the same when using var_dump() to output, the two outputs are float(8.87), they are the same. But when comparing them for equality, the result is weird., they are not equal. Why?To analyze this question, we need to start with PHP data types. PHP uses weak types. In PHP...

   PHP,floating, precision,compare,equality     2012-06-27 09:01:36

  Windows 8.1 will be released on October 18

According to TheVerge, Microsoft Windows 8.1 will be released on October 18. Windows 8 users can download the free update on Windows Store one day before the release date, There will be a formal release press on October 18. In next few weeks, Windows 8 RTM will be open to PC manufacturers and partners. In this year's WPC, Microsoft demonstrated their latest Windows 8.1 on various devices most of the time, including the 8-inch Tablet PC, laptops, desktops and even streamed content from PC to Xbo...

   Windows 8.1,Release date     2013-08-14 11:49:09

  C++ : string beginWith and endWith

C++ is an very powerful programming language. It is efficient and flexible. When writing C++ programs, we may often need to process strings and often we need to check whether a string begin with some substring or end with some substring. We can use following functions to ahieve these:     static bool beginWith(const std::string str,const std::string needle){        return (!str.compare(0,needle.length(),needle));    }    ...

   C++,beginWith,endWith,     2012-08-31 06:53:44

  Dates in PHP and MySQL

I see a lot of people on forums and on my training courses asking about the best way (or any way) to manage dates stored in a MySQL database and used in PHP. Three options follow, but first the problem.PHP uses unix timestamps for all its date functionality. It has methods to convert these timestamps into pretty much any text format you could want but internally it uses the timestamp format. A timestamp is simply an integer. Specifically, it’s the number of seconds that have ela...

   PHP,MySQL,Date format,Date,Comparison,Date compare     2011-10-17 14:00:57

  Update parent window after closing the window opened by window.open()

Imagine we have a webpage which has a text field to let user enter a date. Usually, we may create a calendar window to ask the user to pick one date from the calendar window, when the date is picked, the calendar window will close and the date picked will be put into the text field. This way involves the window.open() method in JavaScript, and we may think how the opened window knows its parent window and then updates the parent window. I give a simple demo on this.We have two pages, on is the p...

   window.open, JavaScript,update, return value     2012-06-23 01:36:32

  What will the value of Integer.valueOf(127) == Integer.valueOf(127) be in Java?

Do you really understand how Java does the integer comparison? OK, ignore the statements in the post title. What we are interested in is another set of comparison statements. Let's first see below code snippet. public class IntegerComparison { public static void main(String[] args) { Integer a = 127, b = 127; Integer c = 128, d = 128; System.out.println(a == b); System.out.println(c == d); } } What do you think the output will be? Are they both displaying true? You will find out t...

   JAVA,==,EQUALSTO     2018-01-13 22:18:15