pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <bdo id='KSoGp'></bdo><ul id='KSoGp'></ul>

    <small id='KSoGp'></small><noframes id='KSoGp'>

    1. <tfoot id='KSoGp'></tfoot>

      <legend id='KSoGp'><style id='KSoGp'><dir id='KSoGp'><q id='KSoGp'></q></dir></style></legend>

      <i id='KSoGp'><tr id='KSoGp'><dt id='KSoGp'><q id='KSoGp'><span id='KSoGp'><b id='KSoGp'><form id='KSoGp'><ins id='KSoGp'></ins><ul id='KSoGp'></ul><sub id='KSoGp'></sub></form><legend id='KSoGp'></legend><bdo id='KSoGp'><pre id='KSoGp'><center id='KSoGp'></center></pre></bdo></b><th id='KSoGp'></th></span></q></dt></tr></i><div class="5v7nf57" id='KSoGp'><tfoot id='KSoGp'></tfoot><dl id='KSoGp'><fieldset id='KSoGp'></fieldset></dl></div>

      無法格式化默認的 MySQL 日期時間

      Unable to format default MySQL datetime(無法格式化默認的 MySQL 日期時間)
        <tbody id='11jtC'></tbody>
        <tfoot id='11jtC'></tfoot>

          <bdo id='11jtC'></bdo><ul id='11jtC'></ul>

            <small id='11jtC'></small><noframes id='11jtC'>

              <legend id='11jtC'><style id='11jtC'><dir id='11jtC'><q id='11jtC'></q></dir></style></legend>

                <i id='11jtC'><tr id='11jtC'><dt id='11jtC'><q id='11jtC'><span id='11jtC'><b id='11jtC'><form id='11jtC'><ins id='11jtC'></ins><ul id='11jtC'></ul><sub id='11jtC'></sub></form><legend id='11jtC'></legend><bdo id='11jtC'><pre id='11jtC'><center id='11jtC'></center></pre></bdo></b><th id='11jtC'></th></span></q></dt></tr></i><div class="d7v7rpd" id='11jtC'><tfoot id='11jtC'></tfoot><dl id='11jtC'><fieldset id='11jtC'></fieldset></dl></div>
                本文介紹了無法格式化默認的 MySQL 日期時間的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我的日期從數(shù)據(jù)庫中出來是這樣的:2013-11-21 17:43:20

                我正在嘗試使用 Angular 的日期過濾器將它們變成更漂亮的東西,但是...

                {{Objected.created |日期:'shortDate'}}

                {{Objected.created |日期:'YYYY'}}

                ...只是吐出原始日期時間字符串:2013-11-21 17:43:20.沒有錯誤.我做錯了什么?

                更新我看到 MySQL 的默認日期時間與 Angular 的數(shù)據(jù)過濾器所期望的不兼容.我正在嘗試像這樣即時轉(zhuǎn)換它,但它拋出錯誤:

              1. {{ new Date(result.Job.created).toISOString() |日期:'shortDate'}}
              2. 我懷疑我無法以我嘗試的方式實例化 Date 類.錯誤是 $parse:syntax 錯誤.

                更新

                感謝@m59 的幫助,我通過一些小的調(diào)整讓它工作......

                HTML:

                ...{{Object.created |dateToISO |日期:'shortDate'}}

                JS:

                var myApp = angular.module('myApp',[]);myApp.filter('dateToISO', function() {返回函數(shù)(輸入){input = new Date(input).toISOString();返回輸入;};});

                這個自定義過濾器將默認的 MySQL 日期時間轉(zhuǎn)換為日期過濾器期望的格式,所以我發(fā)送它一個又一個然后瞧".

                解決方案

                您需要將日期字符串轉(zhuǎn)換為 Angular 支持的格式,例如 ISO 8601 格式.你可以這樣轉(zhuǎn)換:

                $scope.Object.created = new Date($scope.Object.created).toISOString();

                此處進行現(xiàn)場演示(點擊).

                要即時執(zhí)行此操作,您需要一個自定義過濾器.現(xiàn)場演示(點擊).

                標記:

                {{Object.created |dateToISO |日期:'shortDate'}}

                JavaScript:

                app.filter('dateToISO', function() {返回函數(shù)(輸入){返回新日期(輸入).toISOString();};});

                更新:

                這是一種手動轉(zhuǎn)換日期的簡單方法 (firefox):

                app.filter('badDateToISO', function() {返回函數(shù)(壞時間){var goodTime = badTime.replace(/(.+) (.+)/, "$1T$2Z");回歸美好時光;};});

                My dates come out of the database looking like this: 2013-11-21 17:43:20

                I'm trying to user Angular's date filter to turn them into something prettier, but...

                {{Objected.created | date:'shortDate'}}
                

                or

                {{Objected.created | date:'YYYY'}}
                

                ...just spits out the original datetime string: 2013-11-21 17:43:20. There are no errors. What am I doing wrong?

                Update I see that MySQL's default datetime is incompatible with what Angular's data filter expects. I'm attempting to convert it on the fly like this but it's throwing errors:

                <li ng-repeat="result in data">{{ new Date(result.Job.created).toISOString() | date:'shortDate'}}</li>
                

                I suspect I can't instantiate the Date class in the way I'm trying. The error is a $parse:syntax error.

                Update

                Thanks to @m59's help, I got it working with a few minor adjustments...

                HTML:

                <html ng-app="myApp">
                ...
                {{Object.created | dateToISO | date:'shortDate'}}
                

                JS:

                var myApp = angular.module('myApp',[]);
                
                myApp.filter('dateToISO', function() {
                  return function(input) {
                    input = new Date(input).toISOString();
                    return input;
                  };
                });
                

                This custom filter converts the default MySQL datetime into the format that the date filter expects, so I send it throw one then another and "voila".

                解決方案

                You need to convert your date string to something supported by Angular, like ISO 8601 format. You could convert it like this:

                $scope.Object.created = new Date($scope.Object.created).toISOString();
                

                Live demo here (click).

                To do this on the fly, you need a custom filter. Live demo here (click).

                Markup:

                <div>{{Object.created | dateToISO | date:'shortDate'}}</div>
                

                JavaScript:

                app.filter('dateToISO', function() {
                  return function(input) {
                    return new Date(input).toISOString();
                  };
                });
                

                Update:

                Here's a simple way to convert your date manually (firefox):

                app.filter('badDateToISO', function() {
                  return function(badTime) {
                    var goodTime = badTime.replace(/(.+) (.+)/, "$1T$2Z");
                    return goodTime;
                  };
                });
                

                這篇關(guān)于無法格式化默認的 MySQL 日期時間的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產(chǎn)品、類別和元數(shù)據(jù)的 SQL 查詢 woocommerce/wordpress)
                How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統(tǒng))中使用 MySQL?)
                PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任務計劃程序中的 PowerShell MySQL 備份腳本錯誤 0x00041301)
                Import the data from the XML files into a MySQL database(將數(shù)據(jù)從 XML 文件導入 MySQL 數(shù)據(jù)庫)
                installed Xampp on Windows 7 32-bit. Errors when starting(在 Windows 7 32 位上安裝 Xampp.啟動時的錯誤)
                Mysql lower case table on Windows xampp(Windows xampp 上的 Mysql 小寫表)

                    <bdo id='AI2PN'></bdo><ul id='AI2PN'></ul>
                  • <i id='AI2PN'><tr id='AI2PN'><dt id='AI2PN'><q id='AI2PN'><span id='AI2PN'><b id='AI2PN'><form id='AI2PN'><ins id='AI2PN'></ins><ul id='AI2PN'></ul><sub id='AI2PN'></sub></form><legend id='AI2PN'></legend><bdo id='AI2PN'><pre id='AI2PN'><center id='AI2PN'></center></pre></bdo></b><th id='AI2PN'></th></span></q></dt></tr></i><div class="n5zl7j7" id='AI2PN'><tfoot id='AI2PN'></tfoot><dl id='AI2PN'><fieldset id='AI2PN'></fieldset></dl></div>
                  • <tfoot id='AI2PN'></tfoot>
                    <legend id='AI2PN'><style id='AI2PN'><dir id='AI2PN'><q id='AI2PN'></q></dir></style></legend>
                      <tbody id='AI2PN'></tbody>

                      <small id='AI2PN'></small><noframes id='AI2PN'>

                          主站蜘蛛池模板: 桨叶搅拌机_螺旋挤压/方盒旋切造粒机厂家-无锡市鸿诚输送机械有限公司 | 国资灵活用工平台_全国灵活用工平台前十名-灵活用工结算小帮手 | 诺冠气动元件,诺冠电磁阀,海隆防爆阀,norgren气缸-山东锦隆自动化科技有限公司 | CCE素质教育博览会 | CCE素博会 | 教育展 | 美育展 | 科教展 | 素质教育展 | 鲸鱼视觉 -数字展厅多媒体互动展示制作公司| 写方案网_方案策划方案模板下载 事迹材料_个人事迹名人励志故事 | 钢衬玻璃厂家,钢衬玻璃管道 -山东东兴扬防腐设备有限公司 | 自动钻孔机-全自动数控钻孔机生产厂家-多米(广东)智能装备有限公司 | 色油机-色母机-失重|称重式混料机-称重机-米重机-拌料机-[东莞同锐机械]精密计量科技制造商 | 葡萄酒灌装机-食用油灌装机-液体肥灌装设备厂家_青州惠联灌装机械 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-北京罗伦过滤技术集团有限公司 | 物联网卡_物联网卡购买平台_移动物联网卡办理_移动联通电信流量卡通信模组采购平台? | 石膏基自流平砂浆厂家-高强石膏基保温隔声自流平-轻质抹灰石膏粉砂浆批发-永康市汇利建设有限公司 | 脉冲布袋除尘器_除尘布袋-泊头市净化除尘设备生产厂家 | 山西3A认证|太原AAA信用认证|投标AAA信用证书-山西AAA企业信用评级网 | 新型锤式破碎机_新型圆锥式_新型颚式破碎机_反击式打沙机_锤式制砂机_青州建源机械 | 伶俐嫂培训学校_月嫂培训班在哪里报名学费是多少_月嫂免费政府培训中心推荐 | 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 真空上料机(一种真空输送机)-百科 | 油罐车_加油机_加油卷盘_加油机卷盘_罐车人孔盖_各类球阀_海底阀等车用配件厂家-湖北华特专用设备有限公司 | 福建自考_福建自学考试网 | 中红外QCL激光器-其他连续-半导体连续激光器-筱晓光子 | 电池挤压试验机-自行车喷淋-车辆碾压试验装置-深圳德迈盛测控设备有限公司 | 超声波_清洗机_超声波清洗机专业生产厂家-深圳市好顺超声设备有限公司 | 单级/双级旋片式真空泵厂家,2xz旋片真空泵-浙江台州求精真空泵有限公司 | 全自动包衣机-无菌分装隔离器-浙江迦南科技股份有限公司 | 氧化锆纤维_1800度高温退火炉_1800度高温烧结炉-南京理工宇龙新材料股份有限公司 | 无锡网站建设_企业网站定制-网站制作公司-阿凡达网络 | 水性绝缘漆_凡立水_绝缘漆树脂_环保绝缘漆-深圳维特利环保材料有限公司 | 宏源科技-房地产售楼系统|线上开盘系统|售楼管理系统|线上开盘软件 | 齿轮减速马达一体式_蜗轮蜗杆减速机配电机-德国BOSERL齿轮减速电动机生产厂家 | 海南在线 海南一家| 橡胶粉碎机_橡胶磨粉机_轮胎粉碎机_轮胎磨粉机-河南鼎聚重工机械制造有限公司 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 高压管道冲洗清洗机_液压剪叉式升降机平台厂家-林君机电 | 西安标准厂房_陕西工业厂房_西咸新区独栋厂房_长信科技产业园官方网站 | 皮带机_移动皮带机_大倾角皮带机_皮带机厂家 - 新乡市国盛机械设备有限公司 | 杭州月嫂技术培训服务公司-催乳师培训中心报名费用-产后康复师培训机构-杭州优贝姆健康管理有限公司 | 我爱古诗词_古诗词名句赏析学习平台 | 污水/卧式/潜水/钻井/矿用/大型/小型/泥浆泵,价格,参数,型号,厂家 - 安平县鼎千泵业制造厂 | 除湿机|工业除湿机|抽湿器|大型地下室车间仓库吊顶防爆除湿机|抽湿烘干房|新风除湿机|调温/降温除湿机|恒温恒湿机|加湿机-杭州川田电器有限公司 |