我想使用newImg=np.where((img>threshold)[..., None],color1,color2)
通过以下方式将当前日期和时间转换为。
使用JavaScript 新Date():moment.js
的当前日期和时间,并希望将上述格式转换为以下提到的格式。
Thu Jul 12 2018 09:28:51 GMT+0530 (India Standard Time)
答案 0 :(得分:2)
您可以了解有关formatting with moment.js here.
的更多信息以escaping-characters "[]".格式对单词进行转义
public class TestingThreads {
public static void main(String[] args) {
Thread workerThread = new Thread(new WorkerThread());
workerThread.run();
}
public static class WorkerThread implements Runnable {
private ConfigService service;
@Override
public void run() {
Response response = new Response() {
@Override
public void onResponse(String result) {
//Do something on the response
}
};
Request request = new Request();
service.callSomething(request, response);
//Wait for response before exiting this run loop
}
}
public static abstract class Response {
public abstract void onResponse(String result);
}
public static class Request {
}
public static class ConfigService {
public void callSomething(Request request, Response response) {
// Call Long Running Process
}
}
}
console.log(moment());
console.log(moment().format('ddd, DD MMM YYYY HH:mm:ss [GMT]'));
console.log(moment().format('YYYY-MM-DD[T]HH:mm:ss[Z]'));
答案 1 :(得分:1)
您可以使用toGMTSting方法将本地时间转换为GMT格式。希望对您有所帮助。
console.log(new Date().toGMTString());
console.log(new Date("Fri Jan 20 2012 11:51:36 GMT-0530").toGMTString());
答案 2 :(得分:1)
您也可以尝试以下操作
- nodejs
var moment = require('moment');
var format1 = moment().utcOffset(330).format('ddd, DD MMM YYYY HH:mm:ss [GMT]')
var format2 = moment().toDate();
console.log(format1);
console.log(format2);
- 角形
import moment from 'moment';
var format1 = moment().utcOffset(330).format('ddd, DD MMM YYYY HH:mm:ss [GMT]')
var format2 = moment().toDate();
console.log(format1);
console.log(format2);
安装如下所示的时刻
npm install --save moment
- HTML javascript
var format1 = moment().utcOffset(330).format('ddd, DD MMM YYYY HH:mm:ss [GMT]')
var format2 = moment().toDate();
console.log(format1);
console.log(format2);
瞬间源脚本
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
答案 3 :(得分:0)
您也可以尝试以下方法:
var moment = require('moment')
;
let startDate= new moment('11/22/1990','MM/DD/YYYY').format("YYYY/MM/DD");
您还可以了解以下内容:
let otherDate= 1399919400000;
var neweDate = moment(otherDate).format('DD/MM/YYYY');
//My neweDate output is "13/05/2014";
moment.locale('cs');
console.log(moment.locale()); // en
moment("2010-10-20 4:30", "YYYY-MM-DD HH:mm"); // parsed as 4:30 local time
moment("2010-10-20 4:30 +0000", "YYYY-MM-DD HH:mm Z"); // parsed as 4:30 UTC
您还可以验证日期:
moment("not a real date").isValid(); // false
moment("2010 13", "YYYY MM").isValid(); // false (not a real month)
moment("2010 11 31", "YYYY MM DD").isValid(); // false (not a real day)
moment("2010 2 29", "YYYY MM DD").isValid(); // false (not a leap year)
moment("2010 notamonth 29", "YYYY MMM DD").isValid(); // false (not a real month name)
您可以使用现有的本机Javascript Date对象创建Moment。
var day = new Date(2011, 9, 16);
var dayWrapper = moment(day);
您可以使用数字数组创建时刻,以反映传递给新Date()的参数
[year, month, day, hour, minute, second, millisecond]
moment([2010, 1, 14, 15, 25, 50, 125]); // February 14th, 3:25:50.125 PM
过去一年的任何值都是可选的,并且默认为可能的最小值。
moment([2010]); // January 1st
moment([2010, 6]); // July 1st
moment([2010, 6, 10]); // July 10th