I have my code :

我有我的代码:

<input type="date" class="form-control" id="training_date" 
name="training_date" placeholder=" select" value="" 
onfocus="(this.type='date')" 
onfocusout="(this.type='date')" max=<?php echo date('Y-m-d'); ?>>

I need to display my date in following date-format dd-mm-yyyy format in the textbox.

我需要在文本框中以下列日期格式dd-mm-yyyy格式显示我的日期。

3 个解决方案

#1


0

What I would recommend is to make a array with the 12 months of the year (because the will never change)

我建议的是在一年中的12个月制作一个阵列(因为永远不会改变)

_currentDate() {
    var date = new Date();
    for (var i = 0; this.months.length > i; i++) {
      if (date.getMonth() === i) {
        var displayMonth = this.months[i].month;
      }
    }
    var displayDate = date.getDate() + ' ' + displayMonth + ' ' + date.getFullYear();
    return displayDate;
  }

Use the value that you return in your function you just need to insert where you want to display it so in your case your input

使用您在函数中返回的值,只需要插入要显示的值,以便输入您的输入

Hope this helps :)

希望这可以帮助 :)

更多相关文章

  1. 删除复制+粘贴的富文本格式? (跨浏览器)
  2. 用Node.js编写格式化的JSON
  3. 我可以使用onBlur事件对TextBox进行日期检查吗?
  4. Day.js :一个轻量的处理时间和日期的 JavaScript 库
  5. 使用Isotop过滤日期
  6. 如何使用Require JS配置具有第三方js依赖项的日期选择器?
  7. 第三节(JavaScript 对象、日期,函数)
  8. 希望日期开始结束在一个数组中的while循环中为一个房间ID
  9. Javascript日期/时间函数是否依赖于客户端机器?

随机推荐

  1. android HTTPURLConnection解决不能访问H
  2. Android Firebase Dynamic Links 动态链
  3. 关于安卓 TextView 添加点击事件
  4. Android(安卓)studio的NDK配置
  5. 安卓 相对布局属性大全
  6. Android(安卓)Studio启动崩溃的问题:Start
  7. android屏幕页面实现滚动,页面跳…
  8. Android(安卓)获取并解析网络XML与数据上
  9. Android Studio创建Android Library发布
  10. Android NDK 的学习之旅-----JNI LOG 打