Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

394
Views
How to get dd-mm-yyyy format date in datatable laravel

I get the serverside data from controller, and get data using ajax. This is my datatable script.

// Data table
        var table = $('.data-table').DataTable({
            processing: true,
            serverSide: true,
            responsive: true,
            ajax: "quotation",
            dom: '<"top"fB>rt<"bottom"lip><"clear">',
            columns: [{
                    data: 'quotation_no',
                    name: 'quotation_no'
                },
                {
                    data: 'remarks',
                    name: 'remarks'
                },
                {
                    data: 'quotation_date',
                    name: 'quotation_date'
                },
                {
                    data: 'quotation_category',
                    name: 'quotation_category'
                },
                {
                    data: 'quotation_status',
                    name: 'quotation_status'
                },
                {
                    data: 'action',
                    name: 'action',
                    orderable: false,
                    searchable: false
                },
            ],
            "lengthMenu": [
                [10, 25, 50, -1],
                [10, 25, 50, "All"]
            ],
        });

default format for quotation_date is yyyy-mm-dd . How to make dd-mm-yyyy?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can do something like this in the Model.

/**
    * The attributes that should be cast.
    *
    * @var array
    */
    protected $casts = [
       'quotation_date' => 'datetime:d-m-Y',
    ];

Or, alternatively you can also use Carbon Date in the controller:

$quotationDate = Carbon::parse($item['quotation_date'])->format('d-m-Y');
about 4 years ago · Juan Pablo Isaza Report

0

Just add in your model $casts attr if you use eloquent for getting data from DB.

protected $casts = [
    'quotation_date' => 'datetime:d-m-Y',
];

After it action your date format will be like dd-mm-yyyy

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!