($width) AND $width .= 'px';
$style = " style=\"width: $width\"";
}
$value = $value ? $value : date('H:i');
$s = " ";
return $s;
}
// form_date('start', '2018-07-05') 为空则当前日期
function form_date($name, $value = 0, $width = FALSE)
{
$style = '';
if (FALSE !== $width) {
is_numeric($width) AND $width .= 'px';
$style = " style=\"width: $width\"";
}
$value = $value ? $value : date('Y-m-d');
$s = " ";
return $s;
}
/**用法
*
* echo form_radio_yes_no('radio1', 0);
* echo form_checkbox('aaa', array('无', '有'), 0);
*
* echo form_radio_yes_no('aaa', 0);
* echo form_radio('aaa', array('无', '有'), 0);
* echo form_radio('aaa', array('a'=>'aaa', 'b'=>'bbb', 'c'=>'ccc', ), 'b');
*
* echo form_select('aaa', array('a'=>'aaa', 'b'=>'bbb', 'c'=>'ccc', ), 'a');
*/
?>组保留的标签 余下为需要删除的标签
unset($oldtag[$key]);
}
}
}
if (!empty($oldtag)) {
$tagids = array();
foreach ($oldtag as $tagid => $tagname) {
$tagids[] = $tagid;
}
well_oldtag_delete($tagids, $tid);
}
$r = well_tag_process($tid, $fid, $create_tag, $tagarr);
return $r;
}
// 删除标签和绑定的主题
function well_oldtag_delete($tagids, $tid)
{
$pagesize = count($tagids);
$arrlist = well_tag_find_by_tagids($tagids, 1, $pagesize);
$delete_tagids = array(); // 删除
$tagids = array();
$n = 0;
foreach ($arrlist as $val) {
++$n;
if (1 == $val['count']) {
// 只有一个主题
$delete_tagids[] = $val['tagid'];
} else {
$tagids[] = $val['tagid'];
}
}
!empty($delete_tagids) and well_tag_delete($delete_tagids);
$arlist = well_tag_thread_find_by_tid($tid, 1, $n);
if ($arlist) {
$ids = array();
foreach ($arlist as $val) $ids[] = $val['id'];
well_tag_thread_delete($ids);
}
!empty($tagids) and well_tag_update($tagids, array('count-' => 1));
}
// 标签数据处理 $arr=新提交的数组 $tagarr=保留的旧标签
function well_tag_process($tid, $fid, $new_tags = array(), $tagarr = array())
{
if (empty($tid)) return '';
// 新标签处理入库
if ($new_tags) {
$threadarr = array();
$tagids = array();
$i = 0;
$size = 5;
$n = count($tagarr);
$n = $n > $size ? $size : $size - $n;
foreach ($new_tags as $name) {
++$i;
$name = trim($name);
$name = stripslashes($name);
$name = strip_tags($name);
$name = str_replace(array(' ', '#', "@", "$", "%", "^", '&', '·', '<', '>', ';', '`', '~', '!', '¥', '……', ';', '?', '?', '-', '—', '_', '=', '+', '.', '{', '}', '|', ':', ':', '、', '/', '。', '[', ']', '【', '】', '‘', ' ', ' ', ' ', ' ', ' '), '', $name);
$name = htmlspecialchars($name, ENT_QUOTES);
if ($name && $i <= $n) {
// 查询标签
$read = well_tag_read_name($name);
if ($read) {
// 存在 count+1
$tagids[] = $read['tagid'];
} else {
// 入库
$arr = array('name' => $name, 'count' => 1);
$tagid = well_tag_create($arr);
FALSE === $tagid and message(-1, lang('create_failed'));
$read = array('tagid' => $tagid, 'name' => $name);
}
$tag_thread = array('tagid' => $read['tagid'], 'tid' => $tid);
$threadarr[] = $tag_thread;
$tagarr[$read['tagid']] = $read['name'];
}
}
!empty($threadarr) and tag_thread_big_insert($threadarr);
!empty($tagids) and well_tag_update($tagids, array('count+' => 1));
}
$json = empty($tagarr) ? '' : xn_json_encode($tagarr);
return $json;
}
?>return $r;
}
/**
* @param int $page 页数
* @param int $pagesize 每页显示数量
* @return mixed
*/
function link_find($page = 1, $pagesize = 100)
{
$arr = link__find($cond = array(), array('rank' => -1), $page, $pagesize);
return $arr;
}
/**
* @param $id
* @return bool 返回FALSE失败 TRUE成功
*/
function link_delete($id)
{
if (empty($id)) return FALSE;
$r = link__delete(array('id' => $id));
link_delete_cache();
return $r;
}
//--------------------------kv + cache--------------------------
/**
* @return mixed 返回全部友情链接
*/
function link_get($page = 1, $pagesize = 100)
{
$g_link = website_get('friends_link');
if (empty($g_link)) {
$g_link = link_find($page, $pagesize);
$g_link AND website_set('friends_link', $g_link);
}
return $g_link;
}
// delete kv and cache
function link_delete_cache()
{
website_set('friends_link', '');
return TRUE;
}
?> $v = implode(",", $v);
$temp[] = $v;
}
// 去掉重复的字符串,也就是重复的一维数组
$temp = array_unique($temp);
// 再将拆开的数组重新组装
$output = array();
foreach ($temp as $k => $v) {
if ($stkeep) $k = $starr[$k];
if ($ndformat) {
$temparr = explode(",", $v);
foreach ($temparr as $ndkey => $ndval) $output[$k][$ndarr[$ndkey]] = $ndval;
} else $output[$k] = explode(",", $v);
}
return $output;
}
// 合并二维数组 如重复 值以第一个数组值为准
function array2_merge($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array1 as $k => $v) {
isset($v[$key]) ? $arr[$v[$key]] = array_merge($v, $array2[$k]) : $arr[] = array_merge($v, $array2[$k]);
}
return $arr;
}
/*
* 对二维数组排序 两个数组必须有一个相同的键值
* $array1 需要排序数组
* $array2 按照该数组key排序
* */
function array2_sort_key($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array2 as $k => $v) {
if (isset($v[$key]) && $v[$key] == $array1[$v[$key]][$key]) {
$arr[$v[$key]] = $array1[$v[$key]];
} else {
$arr[] = $v;
}
}
return $arr;
}
?>
javascript - jquery, work with date - Stack Overflow-软件玩家 - 软件改变生活!
how in jQuery work date?
I want to perform mathematical operations to date.
var date = '2010-11-23 21:32:31';
var date = date - 70;
alert(date);
how get:
2010-11-23 21:31:21
Thanks
how in jQuery work date?
I want to perform mathematical operations to date.
var date = '2010-11-23 21:32:31';
var date = date - 70;
alert(date);
how get:
2010-11-23 21:31:21
Thanks
Share
Improve this question
Follow
edited
Oct 25, 2010 at 19:11
jcolebrand
16k 12 12 gold badges 77 77 silver badges 122 122 bronze badges
asked
Oct 25, 2010 at 19:03
lolalola
lolalola
3,821 20 20 gold badges 64 64 silver badges 98 98 bronze badges
3
There is no "jQuery" way to work with date objects. It's strictly javascript/ECMAscript.
– jcolebrand
Commented
Oct 25, 2010 at 19:07
Edited tags: leaving in jQuery since the original poster asked it.
– jcolebrand
Commented
Oct 25, 2010 at 19:11
1
See related asked a couple hours ago: stackoverflow./questions/4016318/…
– Roatin Marth
Commented
Oct 25, 2010 at 19:26
Add a ment
|
2 Answers
2
Sorted by:
Reset to default
6
Try:
http://www.datejs./
It's not jQuery, but will solve your problems.
From their sample page:
// What date is next thrusday?
Date.today().next().thursday();
// Add 3 days to Today
Date.today().add(3).days();
// Is today Friday?
Date.today().is().friday();
// Number fun
(3).days().ago();
// 6 months from now
var n = 6;
n.months().fromNow();
// Set to 8:30 AM on the 15th day of the month
Date.today().set({ day: 15, hour: 8, minute: 30 });
// Convert text into Date
Date.parse('today');
Date.parse('t + 5 d'); // today + 5 days
Date.parse('next thursday');
Date.parse('February 20th 1973');
Date.parse('Thu, 1 July 2004 22:30:00');
This is not really a jQuery question as it is more a javascript question. For that answer, have a look at this: http://www.w3schools./jsref/jsref_obj_date.asp.
本文标签:
JavaScriptJQuery work with dateStack Overflow
更多相关文章 javascript - JQuery, select first row of table - Stack Overflow I've used JQuery to add a "image" button to a few rows in a table. I used the following
javascript - jQuery, how to find an element by attribute NAME? - Stack Overflow I found many example finding elements by attribute value BUT not with name. I want to find all elements
javascript - JQUERY, Warning Users that IE6 Is Not Supported are wanted - Stack Overflow I'm building an app and have no intentions of support IE6 at this time. To be fair to IE6, I want
javascript - JQuery, bind same function to 3 different textboxs' keyup event - Stack Overflow I have 3 textboxes, and on the keyup event for all 3, I want to call the same function?In the below cod
javascript - jQuery, find li class name (inside ul) - Stack Overflow I have ul with a number of li inside. All li have an id "#category" but different classes (li
javascript - jquery, submit form when field loses focus - Stack Overflow How can I submit a form when a field (In this case the form only has one field) loses focus?I tried thi
JavascriptJquery, open a link with a REL tag as if it were clicked? - Stack Overflow The designer that I am working with on a project implemented a pop-up so that it is called when a stati
javascript - Jquery, php ajax post 500 Internal Server Error returns - Stack Overflow I have some problem with jquery ajax & php. I'm not good in php, but I have to create a login
Javascript + jQuery, applying a blur effect to background images - Stack Overflow Is there a way to apply a "blur" effect on a background image in JavascriptjQuery?[edit] By
javascript - jQuery, Select (any all *) element on Click - Stack Overflow I'm building a debugging tool for myself. What I want it to do is place a class on any element whe
javascript - jQuery, click an element inside its clickable container - how to override - Stack Overflow I have a list o elements li that bees my image carousel. Each element is a thumbnail, and it bees click
javascript - jQuery, hover method and closure - Stack Overflow Have been struggling with Javascript closure for a while trying to wrap brain around function scopes, b
javascript - jQuery, count number of dynamicly added <li> in <ul> - Stack Overflow I have a list of LI in a UL, they are all dynamically added via jQuery. I am trying to alert the number
发表评论