昨天写项目,要把时间戳转换成日期格式发给后端 我就去网上找 看到的一些都不是我想要的 索性自己就写了一个如图

  下面是angular 模式

    $scope.getMyDate = function(str){
str = parseInt(str);
if(str!=""||str!=null){
var oDate = new Date(str);
var oYear = oDate.getFullYear();
var oMonth = oDate.getMonth()+1;
oMonth = oMonth>=10? oMonth:'0'+oMonth;
var oDay = oDate.getDate();
oDay = oDay>=10? oDay:'0'+oDay;
var theDate = oYear+"-"+oMonth+"-"+oDay;
}else{
theDate = "";
}
return theDate
};

  下面是js 模式

  function getMyDate(str){
str = parseInt(str);
if(str!=""||str!=null){
var oDate = new Date(str);
var oYear = oDate.getFullYear();
var oMonth = oDate.getMonth()+1;
oMonth = oMonth>=10? oMonth:'0'+oMonth;
var oDay = oDate.getDate();
oDay = oDay>=10? oDay:'0'+oDay;
var theDate = oYear+"-"+oMonth+"-"+oDay;
}else{
theDate = "";
}
return theDate
};

js angular 时间戳转换成日期格式 年月日 yyyy-MM-dd的更多相关文章

  1. js将时间戳转换成日期格式-陈远波

    var timestamp =1539598555000;//时间戳 //时间戳转换成time格式function timestampToTime(timestamp) { var date = ne ...

  2. js中时间戳转换成时间格式

    js中时间戳转换成时间格式, // 时间戳转换成时间格式 var formatDate = function(date){ date = new Date(date); var y=date.getF ...

  3. vue 将时间戳转换成日期格式 (一)

    (1)创建一个处理时间格式的js,内容如下: ../../utils/formatDate.js export function formatDate(date, fmt) { if (/(y+)/. ...

  4. jqgrid 时间戳转换成日期格式

    原文 :http://blog.csdn.net/caoyuancsdn/article/details/52984524 Java script  接收到的时间参数是时间戳*1000 functio ...

  5. javaScript中将时间戳转换成日期格式

    function DateFormt(time, format) { ); var o = { , "d+": testDate.getDate(), "h+" ...

  6. js时间戳转成日期格式

    将时间戳转换成日期格式:// 简单的一句代码var date = new Date(时间戳); //获取一个时间对象 注意:如果是uinx时间戳记得乘于1000.比如php函数time()获得的时间戳 ...

  7. 时间戳转换成日期的js

    在项目开发过程中,我们常常需要把时间戳转换成日期.下面这个是我一直使用的js方法,希望能帮助到有需要的朋友.大家如果有更好的方法,请多多指教! js代码如下: //时间戳转换成日期 function ...

  8. javascript时间戳转换成指定格式的日期

    //时间戳转换成指定格式的日期DateTool.IntDatetimeTo = function(time, format){    var testDate = new Date(time);    ...

  9. moment使用,把某个时间时间戳转换成日期

    1.某个时间时间戳转换成日期 moment(时间戳 ).format("YYYYMMDD")   2.获取某个日期当月的最后一天 moment(“2019-04-05”).endO ...

随机推荐

  1. 【KMP+最小循环节】F. Cyclic Nacklace

    https://www.bnuoj.com/v3/contest_show.php?cid=9147#problem/F [题意] 给定一个字符串,问在字符串后最少添加多少个字母,得到的新字符串能是前 ...

  2. 02-js变量学习

    <html> <head> <title>js的变量学习</title> <meta charset="UTF-8"/> ...

  3. Ubuntu系统备份工具大全(官方整理推荐)

    其实官方在系统备份这块已经有Wiki整理和收集各类实用的工具.以下是翻译自官方Wiki的部分文档: 备份工具  wiki文档实用程序 工具 界面 格式类型 Raw/File 支持 远程 增量 差异 自 ...

  4. Windows堆思维导图--Windows pro sp3

    http://bbs.pediy.com/showthread.php?p=1445192#post1445192

  5. 中高级前端应该必会,js实现事件委托代理、切换样式、元素获取相对于文档位置等

    1.介绍 随着组件开发大流行,现在三大框架已经基本占领了整个前端. 这时候,我们要是引入一个 jq 是不是先得你的项目非常臃肿,jq 也很不适合. 这个时候,你就需要来增加你 js 的功底. 2.各种 ...

  6. How to remote debug neutron

    First of all, I will assume that you know how to use pydevd to remote debug normal python program. I ...

  7. 我的arcgis培训照片7

    来自:http://www.cioiot.com/successview-553-1.html

  8. console command

    routes/console.php copy一个默认的 Artisan::command('hello', function () { $this->comment('hello world' ...

  9. k-d树及八叉树

    http://en.wikipedia.org/wiki/K-d_tree http://en.wikipedia.org/wiki/Octree

  10. 托管C++线程锁实现 c++11线程池

    托管C++线程锁实现   最近由于工作需要,开始写托管C++,由于C++11中的mutex,和future等类,托管C++不让调用(报错),所以自己实现了托管C++的线程锁. 该类可确保当一个线程位于 ...