在JavaScript中以Hours24:Minutes:Seconds格式获取当前UTC时间

news/2024/7/19 14:33:32 标签: java, javascript, python, js, ios

在JavaScript中获取当前UTC时间 (Getting current UTC time in JavaScript)

To get the current UTC time in JavaScript, we need to use three library functions of Date class,

要使用JavaScript获取当前UTC时间 ,我们需要使用Date类的三个库函数,

  1. Date getUTCHours() Method – It returns current UTC hours

    Date getUTCHours()方法 –返回当前UTC时间

  2. Date getUTCMinutes() Method – It returns current UTC minutes

    Date getUTCMinutes()方法 –返回当前UTC分钟

  3. Date getUTCSeconds() Method – It returns current UTC seconds

    Date getUTCSeconds()方法 –返回当前UTC秒

Note: To call these functions, we need to create an object to the Date class using Date class constructor.

注意:要调用这些函数,我们需要使用Date类的构造函数为Date类创建一个对象。

Examples:

例子:

    Date class constructor:
    var dt = new Date();

    Function calls:
    dt.getUTCHours();
    dt.getUTCMinues();
    dt.getUTCSeconds();
    
    Output:
    18
    22
    38

JavaScript code to get the current UTC time in Hours24: Minutes: Seconds format

JavaScript代码以Hours24:Minutes:Seconds格式获取当前UTC时间

<html>
<head><title>JavaScipt Example</title></head>

<body>
<script>
	var dt = new Date(); //Date constructor 
	var hh = dt.getUTCHours();
	var mm = dt.getUTCMinutes();
	var ss = dt.getUTCSeconds();
	//printing time
	document.write("Current UTC time is= " + hh + ":" + mm + ":" + ss + "<br>");
</script>
</body>
</html>

Output

输出量

Current UTC time is= 18:22:38


翻译自: https://www.includehelp.com/code-snippets/get-current-utc-time-in-hours24-minutes-seconds-format-in-javascript.aspx


http://www.niftyadmin.cn/n/1253730.html

相关文章

洛谷P3865 ST表

传送门啦 思路&#xff1a; $ f[i][j] $ 表示从 $ i $ 开始&#xff0c;包含 $ 1<<j $ 个元素的区间的区间最大值&#xff1b; 转移方程: $ f[i][j]max_(f[i][j-1],f[i(1<<j-1)][j-1] $ ; 查询 $ (l,r) $ : $ plog_2(r-l1) $ ; $ max(l,r)max(f[l][p],f[r-(1<&l…

关于专线映射问题

最近布置高管局的oa系统&#xff0c;然后碰到了专线ip如何映射的问题&#xff0c;今天给大家分享一下。 关于映射&#xff0c;首先要解决的问题是在局域网中的访问&#xff0c;如何在局域网中访问你的项目呢&#xff1f;我这边用的是PHPstudy 1.打开vhost 2.将你项目的ServerNa…

c语言 递归拆分数字_C程序使用递归在数字数组中找到最大的数字

c语言 递归拆分数字Problem statement: Write a C Program to find the Biggest Number in an Array of integers (can be negative too) using Recursion. 问题陈述&#xff1a;编写一个C程序&#xff0c;以使用Recursion在整数数组中查找最大数(也可以为负数) 。 Algorithm:…

零基础英文盲打的建议

巧妇难为无米之炊之——工具篇 其实个人觉得金山打字通就不错了&#xff0c;对于喜欢二指禅的同学来说&#xff0c;强烈建议从英文开始&#xff0c;尤其是从它的新手入门开始&#xff0c;一步步掌握基本的指法&#xff0c;以及熟悉基本的按键的位置&#xff0c;然后就可以开始自…

springmvc.xml,context.xml和web.xml

1:springmvc.xml配置要点 一般它主要配置Controller的组件扫描器和视图解析器 下为:springmvc.xml文件 1 <?xml version"1.0" encoding"UTF-8"?>2 <beans xmlns"http://www.springframework.org/schema/beans" 3 xmlns:xsi"…

蚂蚁金融科技守护金融安全,蚂蚁风险大脑助阵

摘要&#xff1a;以“数字金融新原力(The New Force of Digital Finance)”为主题&#xff0c;蚂蚁金服ATEC城市峰会于2019年1月4日上海如期举办。金融智能专场分论坛上&#xff0c;蚂蚁金服大安全副总经理王黎强做了主题为《金融科技守护金融安全》的精彩分享。 演讲中&#x…

WPF触发器(Trigger) - DataTrigger

WPF触发器(Trigger) - DataTrigger 原文:WPF触发器(Trigger) - DataTrigger官方文档中对DataTrigger的介绍 Represents a trigger that applies property values or performs actions when the bound data meets a specified condition. 某词典的翻译: 当绑定的数据满足指定的条…

python框架经典案例

轮播收藏 分页器的实现 阿里云短信业务 阿里云支付业务 验证码的制作 邮箱验证 商城项目 个人博客项目