Wednesday, November 23, 2011

Comparing 10-digit unix date with other date format in MySQL

If the date is stored in the database in 10-digit Unix format such as "1203683582" and you wish to do comparision with other date formats, do something like this:

FROM mytable
Remember to use the date within UNIX_TIMESTAMP() function in yyyy-mm-dd international standard (this is a default format used by MySQL anyway). Passing the date in dd/mm/yyyy format does not work. If you do not pass the time in the UNIX_TIMESTAMP(), the time defaults to 00:00:00.

Checkbox toggling with jQuery

<input id="mycheckbox" name="mycheckbox" type="checkbox" value="Y" />My Checkbox - click to toggle
<div id="mydiv" style="display:none;">This is a div that's to be shown/hidden.</div>
Here "mycheckbox" is the checkbox id and "mydiv" is the id of div that you want shown/hidden when toggling the checkbox.

See example below:

My Checkbox - click to toggle

Sunday, November 13, 2011

CSS Hack: Opacity on IE

If you want to get opacity to work on all IE browsers, use the following IE filters in the order:
.opaque {
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; // for IE8/9
  filter: alpha(opacity=50);  // for IE5-7
  opacity: .5;  // for all other browsers    

Note: opacity gets inherited by child elements. So it's better to use background-color:rgba(r,g,b,alpha). For IE browsers, use gradient filter with #argb.

CSS Hack: Using RGBA in IE

background-color: rgba(r,g,b,alpha) is not supported by IE browsers up to IE9. But there is a workaround- by converting rgba() into #argb and using gradient filter.

More information on rgba() to #argb conversion and a simple conversion utility can be found here: 

Once rgba() is converted to #argb, you can then use the gradient opacity filter like this:
zoom: 1;

Saturday, November 12, 2011

Internet Explorer (IE) CSS Hacks with Conditional Comments

This is self explanatory. I have only used this for CSS hacks. This may also work for HTML tags. See the examples below:

<!--[if IE]>
Conditional comment for IE
<style type="text/css">
.ie { padding:5px; }
<!--[if IE 6]>
Conditional comment for IE 6
<!--[if IE 7]>
Conditional comment for IE 7
<!--[if IE 8]>
Conditional comment for IE 8
<!--[if IE 9]>
Conditional comment for IE 9
<!--[if gte IE 8]>
Conditional comment for IE 8 or higher
<!--[if lt IE 9]>
Conditional comment for IE lower than 9
<!--[if lte IE 7]>
Conditional comment for IE lower or equal to 7
<!--[if gt IE 6]>
Conditional comment for IE greater than 6
<!--[if !IE]> -->
Conditional comment NOT for IE