25 二 2009 @ 5:54 下午 

if(date_default_timezone_get() != ”Asia/Shanghai”) {
    date_default_timezone_set(“Asia/Shanghai”);
}

Posted By: 大宇
Last Edit: 25 二 2009 @ 05:54 下午

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: php技巧
 14 十 2008 @ 12:06 下午 

function microtime_float()
{
    list($usec, $sec) = explode(” “, microtime());
    return ((float)$usec + (float)$sec);
}

$time_start = microtime_float();

// Sleep for a while
usleep(100);

$time_end = microtime_float();
$time = $time_end – $time_start;

echo “Did nothing in $time seconds\n”;

Posted By: 大宇
Last Edit: 14 十 2008 @ 12:06 下午

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: php
 13 九 2008 @ 9:22 下午 

一.简介

vi是unix世界中最通用的全屏编辑器,linux中是用的是vi的加强版vim,vim同vi完全兼容,vi就是”visual interface”的缩写。它可以执行输出、删除、查找、替换、块操作等众多文本操作,而且用户可以根据自己的需要对其进行定制,这是其它编辑程序所没有的。

vi不是一个排版程序,它不象Word或WPS那样可以对字体、格式、段落等其他属性进行编排,它只是一个文本编辑程序。

vi没有菜单,只有命令,且命令繁多。只要在命令行上键入vi就可进入vi的编辑环境。vi有三种状态:命令模式,文本输入模式和末行模式。键入vi回车后首先进入vi的命令模式。

在命令模式下用户输入的任何字符都被Vi当作命令加以解释执行,如果用户要将输入的字符当作是文本内容时,则首先应将Vi的工作模式从命令模式切换到文本输入模式。在命令模式下,按一下”a”(”A”)键或者”i” (”I”)或者”o”(”O”)键,即进入插入态文本输入模式。按”a”键,插入到当前光标的后面;按”i”键,在当前光标处插入;按”A”键,在当前光标所在行的最后插入;按”I”键,在当前光标所在行的开头插入。在文本输入模式下,按Esc键,即回到命令模式。

More »

Posted By: 大宇
Last Edit: 13 九 2008 @ 09:28 下午

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: Linux
 05 八 2008 @ 3:53 下午 

microtime

(PHP 3, PHP 4, PHP 5)

microtime – 返回当前 Unix 时间戳和微秒数

说明

mixed microtime ( [bool get_as_float] )

microtime() 当前 Unix 时间戳以及微秒数。本函数仅在支持 gettimeofday() 系统调用的操作系统下可用。

如果调用时不带可选参数,本函数以 “msec sec” 的格式返回一个字符串,其中 sec 是自 Unix 纪元(0:00:00 January 1, 1970 GMT)起到现在的秒数,msec 是微秒部分。字符串的两部分都是以秒为单位返回的。

如果给出了 get_as_float 参数并且其值等价于 TRUEmicrotime() 将返回一个浮点数。

注意: get_as_float 参数是 PHP 5.0.0 新加的。

例 1. 用 microtime() 对脚本的运行计时

<?php
/**
* Simple function to replicate PHP 5 behaviour
*/
function microtime_float()
{
    list(
$usec, $sec) = explode(" ", microtime());
    return ((float)
$usec + (float)$sec);
}

$time_start = microtime_float();

// Sleep for a while
usleep(100);

$time_end = microtime_float();
$time = $time_end - $time_start;

echo "Did nothing in $time seconds\n";
?>

Posted By: 大宇
Last Edit: 05 八 2008 @ 03:53 下午

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: php函数
 06 七 2008 @ 1:29 上午 

//0,24时间戳
$time0 = strtotime(“today”);  //有时会出错而导至得到的时间戳与 time()相同

$time0 = strtotime(date(“Y-m-d”));
$time24 = $time0+86399;

Posted By: 大宇
Last Edit: 09 十 2008 @ 10:46 下午

EmailPermalinkComments (0)
Tags
Tags:
Categories: php
 05 七 2008 @ 12:11 上午 

unix_timestamp
列如:“select username from forum_topic where unix_timestamp(now())-unix_timestamp(datetime)<=86400 and forum_name=’$forum’ limit 1”

记录时间,入库时间
添加使用 time()
读取使用 echo gmdate(‘Y-m-d H:i:s’, $book['dateline']);
这种方法要比使用 now( ) 要好读取速度也比较快

Posted By: 大宇
Last Edit: 05 七 2008 @ 12:16 上午

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: php

 Last 50 Posts
Change Theme...
  • Users » 1
  • Posts/Pages » 165
  • Comments » 12
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

关于



    No Child Pages.

Linux命令手册



    No Child Pages.

php.ini配置



    No Child Pages.

Memcache协议



    No Child Pages.