1. <legend id='jN5nZ'><style id='jN5nZ'><dir id='jN5nZ'><q id='jN5nZ'></q></dir></style></legend>
    <tfoot id='jN5nZ'></tfoot>
      <bdo id='jN5nZ'></bdo><ul id='jN5nZ'></ul>
    1. <small id='jN5nZ'></small><noframes id='jN5nZ'>

      <i id='jN5nZ'><tr id='jN5nZ'><dt id='jN5nZ'><q id='jN5nZ'><span id='jN5nZ'><b id='jN5nZ'><form id='jN5nZ'><ins id='jN5nZ'></ins><ul id='jN5nZ'></ul><sub id='jN5nZ'></sub></form><legend id='jN5nZ'></legend><bdo id='jN5nZ'><pre id='jN5nZ'><center id='jN5nZ'></center></pre></bdo></b><th id='jN5nZ'></th></span></q></dt></tr></i><div id='jN5nZ'><tfoot id='jN5nZ'></tfoot><dl id='jN5nZ'><fieldset id='jN5nZ'></fieldset></dl></div>
    2. DateTime 类的对象无法转换为字符串

      Object of class DateTime could not be converted to string(DateTime 类的对象无法转换为字符串)
        <i id='Qvagp'><tr id='Qvagp'><dt id='Qvagp'><q id='Qvagp'><span id='Qvagp'><b id='Qvagp'><form id='Qvagp'><ins id='Qvagp'></ins><ul id='Qvagp'></ul><sub id='Qvagp'></sub></form><legend id='Qvagp'></legend><bdo id='Qvagp'><pre id='Qvagp'><center id='Qvagp'></center></pre></bdo></b><th id='Qvagp'></th></span></q></dt></tr></i><div id='Qvagp'><tfoot id='Qvagp'></tfoot><dl id='Qvagp'><fieldset id='Qvagp'></fieldset></dl></div>
          <tbody id='Qvagp'></tbody>
        • <tfoot id='Qvagp'></tfoot>

          1. <legend id='Qvagp'><style id='Qvagp'><dir id='Qvagp'><q id='Qvagp'></q></dir></style></legend>
            1. <small id='Qvagp'></small><noframes id='Qvagp'>

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

                本文介绍了DateTime 类的对象无法转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在名为 Film_Release

                我正在循环,我想在 datetime 中转换它们并将它们展开到另一个表中.我的第二个表有一个名为 Films_Date 的列,格式为 DATE.我收到此错误

                I am looping through and I want to convert them in datetime and roll them out into another table. My second table has a column called Films_Date, with a format of DATE. I am receiving this error

                DateTime 类的对象无法转换为字符串

                Object of class DateTime could not be converted to string

                $dateFromDB = $info['Film_Release'];
                $newDate = DateTime::createFromFormat("l dS F Y",$dateFromDB); //( http:php.net/manual/en/datetime.createfromformat.php)
                

                然后我通过插入命令将 $newdate 插入到表中.

                Then I insert $newdate into the table through an insert command.

                为什么会出现这样的错误?

                Why am I be getting such an error?

                推荐答案

                因为 $newDateDateTime 类型的对象,而不是字符串.文档是明确的:

                Because $newDate is an object of type DateTime, not a string. The documentation is explicit:

                返回根据指定格式的新 DateTime 对象格式.

                Returns new DateTime object formatted according to the specified format.

                如果您想从字符串转换为 DateTime 再转换回字符串以更改格式,请调用 DateTime::format 最后从 DateTime 中获取格式化字符串.

                If you want to convert from a string to DateTime back to string to change the format, call DateTime::format at the end to get a formatted string out of your DateTime.

                $newDate = DateTime::createFromFormat("l dS F Y", $dateFromDB);
                $newDate = $newDate->format('d/m/Y'); // for example
                

                这篇关于DateTime 类的对象无法转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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

                  • <tfoot id='JW9I8'></tfoot>

                    <legend id='JW9I8'><style id='JW9I8'><dir id='JW9I8'><q id='JW9I8'></q></dir></style></legend>
                    • <bdo id='JW9I8'></bdo><ul id='JW9I8'></ul>
                        <tbody id='JW9I8'></tbody>

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