Yii: CActiveForm JUI – JQuery UI Inputs (CJuiDatePicker)

I found it pretty difficult to find a reference for how to integrate a jQuery UI date picker in with my CActiveForm view and model.

This is what I found to work correctly for datepicker, for the model field “dob_date”.

<div>
<?php echo $form->labelEx($model, 'dob_date'); ?>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
   'name' => CHtml::activeName($model, 'dob_date'),
   'value' => $model->attributes['dob_date'],
));
?>
<?php echo $form->error($model, 'dob_date'); ?>
</div>

You might need to wrap a function around $model->attributes['dob_date'] to output it as dd/mm/YYYY from a timestamp if that’s the type of field the model attribute represents

Convert MSSQL timestamp to UNIX timestamp

Today I had to pull a number of datetime fields from MSSQL and update records in MySQL with them, using PHP.

The most efficient way to convert the date-time field to a unix timestamp for inputting into MySQL was the following:

DATEDIFF(s, "19700101", ro_job_date) as ro_job_date,

In this example the field was ro_job_date

19700101 is the 1st Jan 1970, the “unix epoch”.

I didnt have to convert from unix timestamp to MSSQL datetime, but researching the above turned up this snippet for that:

SELECT DATEADD(s, unix_timestamp, '19700101')

where unix_timestamp is your timestamp field

Sliding Doors Contact Display

I’ve been asked a few times how to replicate the expandable social media contacts effect from my contact info on the home page.

It’s a nice effect provided by jQuery and jQuery UI with some CSS bits.

The container for each icon is set to overflow:hidden with a default size of 32px – the same size as the social media icon.

This allows the expansion on hover to happen smoothly with element clipping instead of word-wrap or scrollbars.

While it could be packaged up to be more modular and slick, i’ve put it up as a commented demo here

 

An important part of this simple script which is often overlooked is the “.stop()” call. This helps halt the current animations and stops the jumpy effect you get when multiple slide animations are “queued”.

For this example I’ve used the icons from here: http://theg-force.deviantart.com/art/Social-Icons-hand-drawned-109467069