我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

Carbon :: parse(“25/10/1980”)抛出错误

I'm facing an odd issue, Carbon::parse("25/10/1980") throws the following error:

Exception with message 'DateTime::__construct(): Failed to parse time string (25/12/1980) at position 0 (2): Unexpected character'

While having no problems whatsoever, if month (10) is swapped places with day (25) like this:

Carbon::parse("10/25/1980")

How should I parse the "d/m/Y" string?

Try this:

Carbon::createFromFormat('d/m/Y', '25/10/1980')

This also works (dashes, not slashes)

Carbon::parse ('25-10-1980');

近期文章

  • 将日期转换为2016年8月22日到2016年8月22日? [重复]
  • SQL首次出现,最后出现
  • 将CSV文件上传到服务器[重复]
  • SeoShop API +如何在php中使用curl在产品中添加品牌
  • 如何$ row = mysqli_fetch_assoc($ result),在php中是可能的
  • 解析的数据类型
  • 自定义查询功能laravel
  • 除了第一个单词之外,将字符串数组的所有字符串都设置为小写
  • symfony内置服务器高CPU使用率
  • 仅当用户是管理员时才显示链接
  • PHP如何使URL像product.php?id = 1
  • 结合2个sql语句
  • 从文件名字符串中移除空格PHP [复制]
  • 匹配哈希包含
  • 有没有办法在MySQL中优化复杂的数学查询?
  • PHP - 使用文本字符串中的键创建数组
  • 无法删除数据库行,因为它具有外键
  • woocommerce webhook有效载荷中的自定义值
  • 查找数据数组中的下一个可用时间段
  • 是否可以在没有提交按钮的情况下验证表单?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华