Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandan's avatar
Level 13

can't import data into date format

i was try to data import into database but random number genrate cant store date

usersimport.php

public function model(array $row) {

    return new User([
      
    'Bill_Date' => $row[0],

    'BIll_No' => $row[1],

}

output will be like 44554, 55675

please suggest how to fix it

0 likes
5 replies
vandan's avatar
Level 13

Validator::make($rows->toArray(), [

'1' => 'required|date',
    

])->validate();

i was try this function but nothing work anyone idea how to fix it

bekaskaki's avatar
Level 1

@VANDAN - if you use maatwebsite package for impor data, this is an example :

return new user([
        'UserName'           => $row['UserName'],
        'Password'           => $row['Password'],
 'date'               => \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['date']),
    ]);
vandan's avatar
Level 13

@BEKASKAKI - thank you bro its working i can try last 12 hour but cant find solution you nailed it thanks again

Please or to participate in this conversation.