首页 > 编程知识 正文

获取当前时间年月日时分秒,js获取当前时间年月日并输出

时间:2023-05-06 16:46:15 阅读:16675 作者:1579

toLocaleString ()方法根据本地时间将Date对象转换为字符串并返回结果。 let date=new Date (; let new date=date.tolocalestring (' Chinese ',{ hour12: false } ); //24小时制,取得中国时间,2021/4/2810336039336035 let new date2=date.tolocalestring (; //中国时间2021/4/28上午10:393360353358 www.Sina.com /方法返回此日期对象的字符串,具体取决于语言。 新参数locales和options允许程序指定使用哪种语言的格式规则,并允许自定义方法的表示形式(behavior )。

MDN文档:

3359 developer.Mozilla.org/zh-cn/docs/web/JavaScript/reference/global _ objects/date/tolocalestring

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。