You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用JavaScript获取芬兰(Europe/Helsinki时区)的星期几?

获取芬兰时区当前星期几的JavaScript方案

直接使用JavaScript原生的Intl.DateTimeFormatAPI即可实现需求,无需依赖任何第三方库,示例如下:

代码实现

// 初始化芬兰时区的日期格式化器,指定输出星期几
const helsinkiFormatter = new Intl.DateTimeFormat('zh-CN', {
  timeZone: 'Europe/Helsinki',
  weekday: 'long' // 可选值:'long'/'short'/'narrow',控制显示长度
});

// 获取芬兰时区下的当前星期几
const finlandWeekday = helsinkiFormatter.format(new Date());

console.log(finlandWeekday); // 输出示例:"星期四"

关键参数说明

  • timeZone: 'Europe/Helsinki':强制指定时区为芬兰赫尔辛基,不受你当前所在的越南时区影响
  • weekday 参数:
    • 'long':显示完整星期名称(如"星期四")
    • 'short':显示缩写名称(如"周四")
    • 'narrow':显示极简缩写(如"四")
  • 第一个参数'zh-CN'控制输出语言,若需要英文结果可改为'en-US',输出类似"Thursday"

兼容性

Intl.DateTimeFormat是ES6标准内置API,现代浏览器、Node.js 10及以上版本都原生支持,无需额外配置。

内容的提问来源于stack exchange,提问作者Thanh Nhật

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 18:01:18