ByteNote LogoByteNote

Navigation

  • Blog
  • 工具

    © 2025 ByteNote. All rights reserved.

    JS 日期时间转化年月日

    Mar 23, 202314 min read
    export default function ConvertToDate(datetime: Date): string {
      try {
        const localTime = new Date(datetime.toLocaleString('en-US', { timeZone: 'Asia/Shanghai' }));
        const year = localTime.getFullYear();
        const month = localTime.getMonth() + 1;
        const day = localTime.getDate();
        return `${year}年${month}月${day}日`;
      } catch (error) {
        console.error(`Failed to convert date: ${error}`);
        return '';
      }
    }
    

    相关文章

    nftables 使用 Docker 时遇到网络问题

    解决 Docker 与 nftables 网络冲突的方法包括更改 Docker 网络模式为 host、配置 nftables 规则、使用 Kubernetes 等容器编排工具或更新软件版本。

    Flutter mixin 的代码使用示范

    Flutter 中的 mixin 允许在多个类间共享代码,通过关键字 mixin 定义,并可被多个类继承以使用其方法和属性。

    Typora 离线激活码注销网址

    Typora 用户可通过访问网址 https://store.typora.io/my 注销离线激活码。

    Flutter 点击图片显示大图

    点击Flutter应用中的图片后,通过对话框显示该图片的大图视图。

    解决 Flutter showModalBottomSheet 被键盘遮挡

    解决 Flutter 中 showModalBottomSheet 被键盘遮挡的问题,可通过设置 isScrollControlled 并结合 SingleChildScrollView 和适当 padding 来实现。