search
HomeBackend DevelopmentPHP TutorialAnalyze Yii 2.0's method of time formatting in Grid
Analyze Yii 2.0's method of time formatting in GridAug 09, 2017 pm 02:55 PM
gridmethodformat

This article mainly shares with you the relevant information about formatting time in Grid in Yii 2.0. The article provides detailed sample code for your reference and study. It has certain reference value for everyone. Friends who need it can follow it. Let’s take a look.

This article mainly introduces to you the relevant content about Yii 2.0 formatting time in Grid, and shares it for your reference and study. Let’s take a look at the detailed introduction:

Go directly to the code


<?= GridView::widget([ 
 &#39;dataProvider&#39; => $dataProvider,
 &#39;columns&#39; => [
 [&#39;class&#39; => &#39;yii\grid\SerialColumn&#39;],

 &#39;id&#39;,
 &#39;username&#39;,
 &#39;email:email&#39;,
 &#39;created_at:date&#39;, // 这两个需要显示为 2016.04.10
 &#39;updated_at:date&#39;, // 使用 :date 来格式化时间

 [&#39;class&#39; => &#39;yii\grid\ActionColumn&#39;],
],
]); ?>

When you use :date to format the time, you will find that the displayed time is English, it doesn’t matter, we can configure

In main.php, add a few lines to components


&#39;components&#39; => [

  &#39;formatter&#39; => [
   &#39;dateFormat&#39; => &#39;YYY.MM.dd&#39;,
   &#39;decimalSeparator&#39; => &#39;,&#39;,
   &#39;thousandSeparator&#39; => &#39; &#39;,
   &#39;currencyCode&#39; => &#39;EUR&#39;,
  ],

The above is the detailed content of Analyze Yii 2.0's method of time formatting in Grid. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
光盘格式化是什么光盘格式化是什么Aug 17, 2023 pm 04:02 PM

光盘格式化是指将光盘的文件系统进行重建和清空的过程,在光盘格式化过程中,所有的数据都会被彻底删除,同时文件系统会被重新建立,以便在光盘上重新存储数据。光盘格式化可以用于保护数据安全、修复光盘故障和清除病毒等目的,在进行光盘格式化时,需要备份重要数据、选择适当的文件系统,并耐心等待格式化完成。

提升Java时间日期格式化解析性能的方法提升Java时间日期格式化解析性能的方法Jul 01, 2023 am 08:07 AM

如何优化Java开发中的时间日期格式化解析性能摘要:在Java开发中,时间日期格式化与解析是常见的操作,但是由于时间日期格式复杂多样且处理的数据量庞大,往往会成为性能瓶颈。本文将介绍几种优化Java开发中时间日期格式化解析性能的方法,包括使用缓存、减少对象创建、选择适当的API等。一、引言时间日期格式化与解析在Java开发中非常常见。然而,在实际应用中,由于

修复:Rufus 无法在 Windows PC 中创建可启动 USB 问题修复:Rufus 无法在 Windows PC 中创建可启动 USB 问题Apr 29, 2023 am 09:19 AM

Rufus是一款出色的工具,可以轻松创建可启动的USB驱动器。这个小巧而时尚的工具的效率令人惊叹,通常可以提供无错误的操作。但是,有时创建一个新的可启动USB记忆棒会弹出一些错误消息,从而在刻录过程中绊倒。如果您在使用Rufus时遇到任何困难,您可以按照以下步骤为您的问题找到快速解决方案。修复1–运行驱动器的错误检查器在使用Rufus重试之前,您可以运行驱动器的错误检查器工具来扫描驱动器是否存在任何错误。1.同时按下Windows键+E键打开文件资源管理器。然后,点击“这台电脑

使用fmt.Sprint函数将多个值格式化为字符串并返回,包括类型信息使用fmt.Sprint函数将多个值格式化为字符串并返回,包括类型信息Jul 25, 2023 am 09:01 AM

使用fmt.Sprint函数将多个值格式化为字符串并返回,包括类型信息在Go语言中,fmt包提供了许多函数用于将数据格式化为字符串。其中,fmt.Sprint函数可以将多个值格式化为字符串并返回。与fmt.Sprintf函数不同的是,fmt.Sprint函数返回一个字符串,而不是一个格式化后的字符串。下面是一个使用fmt.Sprint函数的简单示例代码:pa

格式化u盘有什么后果格式化u盘有什么后果Jan 13, 2021 pm 05:32 PM

格式化u盘的后果:1、清空U盘,会将u盘中的文件全部删除;2、可以消除U盘上的一些逻辑性的错误和非顽固性病毒或流氓程序;3、如果经常性反复格式化u盘,会降低U盘的使用寿命。

手把手带你使用CSS Flex和Grid布局实现3D骰子(附代码)手把手带你使用CSS Flex和Grid布局实现3D骰子(附代码)Sep 23, 2022 am 09:58 AM

在前端面试中,经常会问到如何使用 CSS 实现骰子/麻将布局。下面本篇文章给大家介绍一下用CSS 创建一个 3D 骰子(Flex和Grid布局实现3D骰子)的方法,希望对大家有所帮助!

格式化数据分区是什么意思?格式化数据分区是什么意思?Mar 10, 2023 am 11:41 AM

格式化数据分区就是对指定磁盘中的数据分区进行初始化操作,这种操作通常会导致现有分区中所有的文件被清除。磁盘格式化牵涉两个不同的程序:低级与高级格式化。前者处理盘片表面格式化赋与磁片扇区数的特质;低级格式化完成后,硬件盘片控制器(disk controller)即可看到并使用低级格式化的成果;后者处理“伴随着操作系统所写的特定信息”。

手机格式化后能恢复数据吗手机格式化后能恢复数据吗Jun 30, 2023 pm 02:12 PM

手机格式化之后还能恢复数据,只要对手机的数据进行备份就可以恢复。很多手机都自带数据备份功能,若想要恢复被删除或格式化的数据,可以点开手机自带备份功能,按照页面指示进行备份操作。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)