js判斷數字或小數
function checknumber(numval) \d+$|$)/;
if (numval != "") else }}
數字「千分位」形式
「千分位」形式,即從個位數起,每三位之間加乙個逗號,例如,將7654321輸出成7,654,321。
function formatcurrency(num)
// 和php一樣的時間戳格式化函式
// @param format 格式
// @param timestamp 要格式化的時間 預設為當前時間
// @return 格式化的時間字串
function js_date(format, timestamp) else
};var txt_weekdays = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
var txt_ordin = ;
var txt_months = ["", "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
var f = ,
d: function () ,
j: function () ,
l: function () ,
n: function () ,
s: function () ,
w: function () ,
z: function () ,
// week
w: function () else else }},
// month
f: function () ,
m: function () ,
m: function () ,
n: function () ,
t: function () else else }},
// year
l: function () ,
//o not supported yet
y: function () ,
y: function () ,
// time
a: function () ,
a: function () ,
b: function () ,
g: function () ,
g: function () ,
h: function () ,
h: function () ,
i: function () ,
s: function () ,
//u not supported yet
// timezone
//e not supported yet
//i not supported yet
o: function () ,
p: function () ,
//t not supported yet
//z not supported yet
// full date/time
c: function () ,
//r not supported yet
u: function ()
};return format.replace(/[\\]?([a-za-z])/g, function (t, s) else if (f[s]) else
return ret;
});}
日期工具類積累
以下的時間方法是我自己親測沒有問題的,做下記錄 獲取當前系統時間的年份 public static integer getnowyear 獲取系統時間的當年第一天日期 public static string getyearfirst 獲取系統時間的當年最後一天日期 public static st...
js函式慢慢積累
這裡積累著工作中js用的函式,慢慢的積累,以後總能幫到自己。1 js對於浮點數的小數字數的控制 tofixed fractiondigits fractiondigits 為小數字數 2 轉大寫 touppercase 3 js中的字元型轉換成數值型 parseint parsefloat 4 js...
js日期函式積累
fss sfsj 對date的擴充套件,將 date 轉化為指定格式的string 月 m 日 d 小時 h 分 m 秒 s 季度 q 可以用 1 2 個佔位符,年 y 可以用 1 4 個佔位符,毫秒 s 只能用 1 個佔位符 是 1 3 位的數字 例子 new date format yyyy m...