Thursday, 18 December 2014

Yii:: Jquery Mask Input For Date

1. Download Masked Input Plugin by digitalBush
2. If you’re using Yii, create folder js outside the protected folder, store the js file inside there, put this code in your page.
<?php
$cs=Yii::app()->clientScript;
$cs->registerScriptFile(Yii::app()->baseUrl.’/js/jquery.maskedinput-1.2.2.js’,CClientScript::POS_HEAD);
?>
3. Then, assign the field to be masked
<SCRIPT language=”javascript”>
$(‘#date_1′).mask(“99-99-9999″,{placeholder:”_”});
</SCRIPT>

PHP: Add leading zeros to number and convert time 12 to 24 hours and vice versa

PHP:: Add leading zeros to number
$number = 3;
$invoice_no = sprintf(“%07d”, $number);
//output => 0000003

PHP convert time 12 to 24 hours and vice versa

// 24-hour time to 12-hour time
$time_in_12_hour_format  = DATE(“g:i a”, STRTOTIME(“23:15″));
// 12-hour time to 24-hour time
$time_in_24_hour_format  = DATE(“H:i”, STRTOTIME(“3:20 pm”));

PHP Get previous month and end day of last month

PHP Get previous month and end day of last month
//Get previous month and year
$lastmonth = date(“Y-m”,mktime(0, 0, 0, date(“m”)-1, date(“d”), date(“Y”))); //eg .output 2010-09
//Get end date of previous month (use ‘t’)
$endDateOfLastMonth = date(“Y-m-t”, strtotime(“last month”)); //eg. output 2010-09-30

Php Sendmail with xampp in windows server 2008

Php Sendmail with xampp in windows server 2008
Sending mail using PHP in windows server quite difficult and sometimes need extra works..So here is the setup that works with Apache, Xampp, PHP in my windows server 2008.
1. Setup sendmail.ini
In xampp, there is folder sendmail. Open file sendmail.ini and configure this value:
smtp_server=xxx.xx.xx.xxxx
smtp_port=25 (default)
auth_username=xxxxxx@yourdomainmail.com
auth_password=xxxxxx
2. Then setup php.ini in xampp/php folder
SMTP = xxx.xx.xx.xxxx
smtp_port = 25 (default)
sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”      //make sure you check your path is correct
3. Ok Done. Restart your webserver.
You can use phpmailer to send email from your application.

PhpList: warning the temporary directory for uploading is not writable

My step to resolve this error.
2. Create folder ‘tmp’ inside your list folder, then set permission 0777
3. Configure config.php eg:
$tmpdir = ‘/var/www/vhosts/pulaidesaru.com/httpdocs/lists/tmp';
//the dir directory base on your DOCUMENT_ROOT