oblind

学的有点杂,总混,留作备忘吧

php时间函数

字符串转时间

function strtotime ($time, $now = 'time()')

eg:

$t = strtotime('2017-11-18');

echo strtotime('next Sunday', $t), '<br>';//$t后的周日,自然语言,好傻逼

echo strtotime('+5hours');//当前时间5小时后

时间转字符串

function date ($format, $timestamp = null)

date('Y-m-d H:i:s');


javascript

 字符串转时间

let t = new Date('2018-03-06 12:00:00')

时间转字符串

let s = (new Date).getTime()


java

static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());

字符串转时间long t = new Date().getTime()long t = sdf.parse("2018-03-06 12:00:00'").getTime();getTime返回1970-01-01 00:00:00起的毫秒数时间转字符串String s = sdf.format(t);


Delphi

uses SysUtils

ShortDateFormat := 'yyyy-mm-dd';

LongTimeFormat := 'hh:nn:ss';

Application.UpdateFormatSettings := False;


评论