Home Backend Development PHP Tutorial Detailed example of Yii 2.0 formatting time in Grid

Detailed example of Yii 2.0 formatting time in Grid

Jun 16, 2017 am 10:44 AM

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;],
],
]); ?>
Copy after login

When you use :date to format the time, you will find that it is displayed The time is in 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;,
  ],
Copy after login

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

Statement of this Website
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

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 ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Python program to format time in AM-PM format Python program to format time in AM-PM format Aug 28, 2023 pm 05:29 PM

In Python, we have some built-in time functions such as strftime() and datetime.now() which can be used to find the time in AM/PM format. Time in AM/PM format is used in a variety of applications such as user interfaces, reporting and documentation, data visualization, and event scheduling. When the time is between 11:59:00 midnight and 12 noon, we say AM time. Similarly, we can say that the time between 12 o'clock and 11:59:00 midnight is PM. The abbreviations AM/PM are used to indicate the exact time. Syntax uses the following syntax in the example &miinus;strftime('%I:%M:%S%p')strft

Take you step by step to implement 3D dice using CSS Flex and Grid layout (with code) Take you step by step to implement 3D dice using CSS Flex and Grid layout (with code) Sep 23, 2022 am 09:58 AM

In front-end interviews, we are often asked how to implement dice/mahjong layout using CSS. The following article will introduce to you how to use CSS to create a 3D dice (Flex and Grid layout implement 3D dice). I hope it will be helpful to you!

Detailed explanation of the implementation steps of converting American time to Chinese time in PHP Detailed explanation of the implementation steps of converting American time to Chinese time in PHP Mar 27, 2024 pm 06:39 PM

PHP is a commonly used programming language used to develop web applications. In the process of developing web applications, it may involve time conversion in different time zones, such as converting American time to Chinese time. This article will detail the steps on how to use PHP to convert American time to Chinese time and provide code examples. 1. Get the US time First, we need to get the US time. The time zone can be set using PHP's built-in function date_default_timezone_set

How to solve Java time formatting exception (DateTimeFormatException) How to solve Java time formatting exception (DateTimeFormatException) Aug 26, 2023 pm 04:30 PM

How to solve Java time format exception (DateTimeFormatException) Introduction: Java is a widely used programming language, and format exceptions (DateTimeFormatException) are often encountered when processing dates and times. This article will explain how to resolve time formatting exceptions in Java and provide some code examples. 1. What is time formatting exception (DateTimeFormatException) in Java

CSS panel layout properties: grid and grid-template-columns CSS panel layout properties: grid and grid-template-columns Oct 25, 2023 am 08:15 AM

CSS panel layout properties: grid and grid-template-columns In modern web page layout, panel layout is a common design method that can arrange web content in a grid. The grid layout attribute in CSS and the grid-template-columns attribute are the keys to realizing panel layout. 1. Introduction to the grid layout attribute The grid layout attribute is an attribute used to create a grid layout in CSS. By converting HTML

How to format time into a specific string using TIME_FORMAT function in MySQL How to format time into a specific string using TIME_FORMAT function in MySQL Jul 13, 2023 pm 03:55 PM

How to use the TIME_FORMAT function in MySQL to format time into a specific string MySQL is a widely used relational database management system that provides a wealth of functions and operators to process data. In MySQL, there is a very useful function, the TIME_FORMAT function, which can format the time in a specified format and return a string. The basic syntax of the TIME_FORMAT function is as follows: TIME_FORMAT(time,f

HTML Tutorial: How to Use Grid Layout for Grid Average Layout HTML Tutorial: How to Use Grid Layout for Grid Average Layout Oct 19, 2023 am 10:49 AM

HTML Tutorial: How to Use Grid Layout for Grid Average Layout In web design, grid layout (GridLayout) is a commonly used layout method. It can effectively divide web content into multiple columns and perform flexible arrangement and layout. This tutorial will introduce how to use HTML and CSS Grid layout to implement grid average layout, and provide specific code examples. 1. What is grid layout? Grid layout is a layout method that divides the page into columns. These columns can be arranged according to rows and

UniApp implementation techniques for page layout and responsive design UniApp implementation techniques for page layout and responsive design Jul 05, 2023 pm 01:57 PM

UniApp’s implementation skills for implementing page layout and responsive design Introduction: UniApp is a cross-platform development tool based on the Vue.js framework, which can simultaneously develop applications for multiple platforms such as iOS, Android, and H5. This article will introduce how to use UniApp to implement page layout and responsive design, and provide some practical code examples. 1. Page layout Flex layout Flex layout is a commonly used method in page layout, which can automatically adapt to different screen sizes and devices. In UniApp

See all articles