小工具知识网

当前位置: 首页 > 行业知识 > js基础语法大全(时间戳,uuid,字符串转json)

行业知识

js基础语法大全(时间戳,uuid,字符串转json)

2026-11-30 03:59:34 来源:互联网转载

目录

    • 一、获取时间戳
    • 二、获取uuid
    • 三、�index.php/tags-41973.html" >��符串转json格式

      一、获取时间戳

      var times = Math.round(new Date().getTime()/1000).toString();  //获取 10位 时间戳console.log(times);

      二、获取uuid

      function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {     var r = Math.random() * 16 | 0,         v = c == 'x' ? r : (r & 0x3 | 0x8);     return v.toString(16); });}console.log(guid());

      三、字符串转json格式

      var string = '{"p":"n","de":"25","ch":"zy"}';var jsonData = eval('(' + string + ')');console.log(jsonData);
      ()()

上一篇:阿玛逊云服务器

下一篇:轻松上手!网站首页轮播图设置教程,图片轮播设置全攻略!