当前位置: 首页 > news >正文

无锡网站建设 首选无锡立威云商特效视频制作软件app

无锡网站建设 首选无锡立威云商,特效视频制作软件app,wordpress微信免签约支付插件,如何在网站搜关键字我们可以使用国际化API自动的格式化数字或者日期,并且格式化日期或数字的时候是按照各个国家的习惯来进行格式化的,非常的简单; const now new Date(); labelDate.textContent new Intl.DateTimeFormat(zh-CN).format(now);比如说这是按照…

我们可以使用国际化API自动的格式化数字或者日期,并且格式化日期或数字的时候是按照各个国家的习惯来进行格式化的,非常的简单;

const now = new Date();
labelDate.textContent = new Intl.DateTimeFormat('zh-CN').format(now);

在这里插入图片描述

比如说这是按照中国的习惯来进行格式化,我们习惯按照年月日时分秒来排列时间

● 但是这样格式化的话只能出现年月日,时间却没有了

const now = new Date();
const options = {hour: 'numeric',minute: 'numeric',day: 'numeric',month: 'numeric',year: 'numeric',weekday: 'long',
};
labelDate.textContent = new Intl.DateTimeFormat('zh-CN', options).format(now);

在这里插入图片描述

● 我们也可以直在浏览器中自动的获取你的地区,无需手动的去指定地区

const now = new Date();
const options = {hour: 'numeric',minute: 'numeric',day: 'numeric',month: 'numeric',year: 'numeric',weekday: 'long',
};const lacale = navigator.language;
console.log(lacale);labelDate.textContent = new Intl.DateTimeFormat(lacale, options).format(now);

在这里插入图片描述

● 再次回到我们的应用程序,我们给每个用户中定义了国家码,要实现每个人登录按照他国家的习惯来显示时间
在这里插入图片描述

const now = new Date();
const options = {hour: 'numeric',minute: 'numeric',day: 'numeric',month: 'numeric',year: 'numeric',
};
labelDate.textContent = new Intl.DateTimeFormat(currentAccount.locale,options
).format(now);

在这里插入图片描述
在这里插入图片描述

● 除了这些,存取款的时间也需要根据用户国家改变

const formatMovementDate = function (date, locale) {const calcDaysPassed = (date1, date2) =>Math.round(Math.abs(date2 - date1) / (1000 * 60 * 60 * 24));const daysPassed = calcDaysPassed(new Date(), date);if (daysPassed === 0) return '今天';if (daysPassed === 1) return '昨天';if (daysPassed <= 7) return `${daysPassed} 天前`;return new Intl.DateTimeFormat(locale).format(date);// const day = `${date.getDate()}`.padStart(2, 0);// const month = `${date.getMonth() + 1}`.padStart(2, 0);// const year = date.getFullYear();// return `${day}/${month}/${year}`;
};const displayMovements = function (acc, sort = false) {containerMovements.innerHTML = '';const movs = sort? acc.movements.slice().sort((a, b) => a - b): acc.movements;movs.forEach(function (mov, i) {const type = mov > 0 ? 'deposit' : 'withdrawal';const date = new Date(acc.movementsDates[i]);const displayDate = formatMovementDate(date, acc.locale);const html = `<div class="movements__row"><div class="movements__type movements__type--${type}">${i + 1} ${type}</div><div class="movements__date">${displayDate}</div><div class="movements__value">${mov.toFixed(2)}€</div></div>`;containerMovements.insertAdjacentHTML('afterbegin', html);});
};

在这里插入图片描述

大家也可以根据下面的文档详细的学习这个国际化API
INIT

http://www.yayakq.cn/news/425420/

相关文章:

  • 织梦可以仿所有网站吗手机网站全屏
  • 官方网站手机网站建设应注意什么问题
  • 怎么用vps搭建网站丰台区网站建设公司
  • 创意logo设计生成器长沙seo服务哪个公司好
  • 温州苍南网站建设企业网站做电脑营销
  • 北京高级网站开发深圳设计公司名称
  • 寿宁县建设局网站动态视频网站开发
  • django mysql网站开发上海浦东新区做网站
  • qq邮箱做网站如何制作网站板块
  • 在线做免费网站百度度小店申请入口
  • 黑龙江建设银行网站公司网站哪家做的好
  • ps做网站视图大小国外云服务器推荐
  • 网站不允许上传文件手机网站设计模板
  • 沈阳网站马格南摄影网站
  • 电子商务网站建设的方法和工具网站的页面布局
  • 建站cms源码网站为什么显示正在建设中
  • 免费商城网站模板下载口碑营销话题
  • 网站app软件下载安装游戏代理平台一天结一次
  • 海南省建设厅网站首页集团网站建设流程
  • 电商网站建设培训学校关键词查网址
  • 天津百度搜索网站排名建站是什么东西
  • 做seo推广做网站有用吗泰安市房产信息网官网
  • tp框架网站开发参考文献html个人网页源码
  • 为什么想做网站运营泰安网站制作推广
  • 利用分类信息网站做推广广州有几个区分别叫什么
  • 小县城做网站制作图片下载什么软件
  • 做软件需要网站免费设计签名软件
  • 外贸平台哪个网站最好知乎wordpress图片转移
  • 制作购物网站需要多少钱自己做的网站搜索不到
  • 光谷软件园 网站建设做外贸服装的网站