/** * Javascript for convert time (using moment JS) * @author UTC.KongLtn * Last Update: 4/12/2015 */ var clientTimeId = { getArchiveClientTime: ".getArchiveClientTime" }; /** * Client Time Object * @type {{init: Function, convertInArchive: Function, toArchiveTime: Function, getDiffTime: Function, getDateYYMMDD: Function}} */ var clientTime = { init: function(){ this.convertInArchive(); }, /** * Convert to client time in archive page */ convertInArchive : function(){ var archiveArray = $(clientTimeId.getArchiveClientTime); $.each(archiveArray, function(index, val) { var createDateToUTCSeconds = moment.utc(val.textContent).unix(); $(this).text(clientTime.getArchiveTime(createDateToUTCSeconds)); }) }, /** * Get client Time in archive page * @param seconds * @returns string */ getArchiveTime : function(seconds){ var createDate = moment.utc(seconds * 1000); var nowDate = moment.utc(); var diff = nowDate.diff(createDate, "minutes"); var firstText = ""; if (diff < 1440) { firstText = "Today "; } else if (diff < 2880) { firstText = "Yesterday "; } else if (diff >= 2880) { return (createDate.local().format("DD.MM.YYYY HH:mm")); } return firstText+ " "+ createDate.local().format("HH:mm"); }, /** * Get the different past time and current time * @param seconds * @returns string */ getDiffTime: function(seconds) { var createDate = moment.utc(seconds * 1000); var nowDate = moment.utc(); var diff = nowDate.diff(createDate, "seconds"); diff = (diff == 0 || diff == 1) ? 2 : diff; if (2 <= diff && diff <= 45) { return diff + " seconds ago"; } else if ( 86400 < diff ) { return createDate.local().format("DD.MM.YYYY HH:mm"); } else { return createDate.fromNow(); } }, /** * Get date by format YY.MM.DD * @param seconds * @returns string */ getDateYYMMDD : function(seconds) { return moment.utc(seconds*1000).local().format("YY.MM.DD"); } }; $(document).ready(function(){ 'use strict'; if (isGuestId > 0) { //console.log("start"); clientTime.init(); } });
Search
Dec 4, 2015
Convert UTC Time to Client Time by moment JS
Dec 3, 2015
Setup Yii with WAMPP
SETUP YII with WAMPP
1/ copy file from http://www.yiiframework.com/download to c:\wamp\www folder
rename yii-1.1.13.... folder to yii
(c:\wamp\www\yii and the framework itself will be into c:\wamp\www\yii\framework)
2/ on c:\wamp\www creates a file with the extension 'bat' (for example myrun.bat),
then open it and put below code:
set PATH=%PATH%;C:\wamp\bin\php\php5.4.3
cmd
3/ Run myrun.bat file and type (or you can cd to ..wamp/www/ folder and type)
php yii/framework/yiic.php webapp myfirst
4/ Config databases
Create database MySQL and fix file
protected/config/database.php
5/ CRUD Create-Read-Update-Delete
Edit file protected/config/main.php
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'1',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
)
Go to http://localhost/myfirst/index.php?r=gii
1/ copy file from http://www.yiiframework.com/download to c:\wamp\www folder
rename yii-1.1.13.... folder to yii
(c:\wamp\www\yii and the framework itself will be into c:\wamp\www\yii\framework)
2/ on c:\wamp\www creates a file with the extension 'bat' (for example myrun.bat),
then open it and put below code:
set PATH=%PATH%;C:\wamp\bin\php\php5.4.3
cmd
3/ Run myrun.bat file and type (or you can cd to ..wamp/www/ folder and type)
php yii/framework/yiic.php webapp myfirst
4/ Config databases
Create database MySQL and fix file
protected/config/database.php
5/ CRUD Create-Read-Update-Delete
Edit file protected/config/main.php
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'1',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
)
Go to http://localhost/myfirst/index.php?r=gii
Subscribe to:
Posts (Atom)