Simplify date representation and keep only the date part
P粉834840856
P粉834840856 2023-09-03 12:12:21
0
1
434

I am trying to get only the date part from the date representation. My database server is phpmyadmin and I retrieve data through laravel controller. I only need to get the date part, for example 2022-01-24 instead of 2022-01-24T18:30:00.000000Z from the created_at column.

Image phpmyadmin.

Image response

My web.php path is:

Route::get('/fetch/curriculumVitaes', [App\Http\Controllers\Admin\CurriculumVitaesController::class, 'index']);< ;/pre> 

I get data through laravel controller, my function is index():

public function index() { $curriculumVitaes = CurriculumVitaes::where('deleted', '=', '0')->get(); return $curriculumVitaes; }

I retrieve data in front-end vue.js:

 {{ index 1 }} {{ curriculumVitae.created_at }} 

P粉834840856
P粉834840856

reply all (1)
P粉720716934

I am not very familiar with Laravel and have not used Vue.js. But I think you can also solve this problem using core PHP. I've modified your code as shown below. When I retrieve a date from a MySQL database that I want to format, I use date('format', variable). In your case this would result in my code below. The format can be displayed in a variety of ways, including: 'm/d/y', 'd/m/y', 'y/d/m', etc. Where m represents the month, d represents the day, and of course y represents the year.

As @Uwe pointed out, my suggestion is to embed the php code in the vue.js code. However, since I know you use both php and vue.js, I'm still wondering if my modified solution below will work. Or within that range.

 {{ index + 1 }} {{  }} 
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!