@JLRDW - thanks for the reply, I am trying to create a time stamp from the date I am sending. Basically I want to over write the created_at date in my database with the new date.
A timestamp is a succession of characters or encoded data recognizing when a specific occasion happened, normally giving date and time of day, some of the time precise to a little division of a second. I have the same issue for making a current timestamp for https://professionalhomeandofficeservices.com.au/aboutus website. can you share the proper method?
@BOLDSTAR - Glad you figured it out. But, it still doesn't answer the question of why you are converting it to a timestamp because if you are using created_at, it's going to get cast to Carbon when you save it. Try it in Tinker (php artisan tinker) if you aren't convinced:
// From Tinker
>>> $user = User::find(1);
=> App\Models\User {#3602
id: 1,
first_name: "Shawn",
last_name: "Lindstrom",
email: "[email protected]",
username: "slindstrom",
created_at: "2019-04-02 03:28:51",
updated_at: "2019-04-02 03:28:51",
}
>>> $user->created_at = \Carbon\Carbon::now()->timestamp;
// Here we see that created_at is set to the current timestamp
=> 1554316597
>>> $user->save();
=> true
// But, after we save the model and retrieve created_at we see that it's a Carbon instance because it was cast to Carbon when we saved it
>>> $user->created_at
=> Illuminate\Support\Carbon @1554175732 {#3570
date: 2019-04-02 03:28:52.0 UTC (+00:00),
}
// Now, if we actually want a timestamp we have to call the timestamp method
>>> $user->created_at->timestamp
=> 1554316597
@LINDSTROM - well when I try to update my created_at date without using Carbon::parse() it throws an error about trailing data. I am not sure what trailing data is or what about it that carbon does not like.
Ive tried sending the date to be saved as 2 different formats without using carbon
1st
Mon Mar 18 2019 00:00:00 GMT-0500 (Central Daylight Time)