使用javascript从datetime中提取时间 [英] extract time from datetime using javascript

查看:210
本文介绍了使用javascript从datetime中提取时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从日期时间格式中提取时间。

how can i extract time from datetime format.

我的日期时间格式如下所示。

my datetime format is given below.

var datetime =2000-01-01 01:00:00 UTC;

我只想得到时间 01.00 as 01

I only want to get the time 01.00 as 01

推荐答案

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects /日期


Date.prototype.toLocaleTimeString()
返回一个字符串,其中包含当地时间敏感表示该日期的一部分基于系统设置。

Date.prototype.toLocaleTimeString() Returns a string with a locality sensitive representation of the time portion of this date based on system settings.



var time = datetime.toLocaleTimeString();

这篇关于使用javascript从datetime中提取时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆