$combinedDT = date('Y-m-d H:i:s', strtotime('$date $time'));
Date Format 2013-10-14
time format 23:40:19
i'm getting zeros when trying to store into a datetime datatype
The Ethereum merge, a long-awaited shift in the technological underpinnings of the world's second-most valuable cryptocurrency, is scheduled to be complete sometime between Sept. 10 and Sept. 20.
The Merge represents the Ethereum network's shift to proof-of-stake (PoS), its new system (also called a “consensus mechanism”) for authenticating crypto transactions. The new system will replace proof-of-work (PoW), the more power-hungry mechanism pioneered by Bitcoin.
Ethereum 2.0 will involve sharding to drastically increase network bandwidth and reduce gas costs, making it cheaper to send Ethereum, tokens, and interact with smart contracts. There will be fundamental economic changes too, Ethereum 2.0 will allow supports to staking nodes and earn Ethereum as passive income.
All funds will transfer over after The Merge, and ether will still appear as ETH in users' wallets. However, Binance will temporarily pause ETH and ERC-20 token deposits and withdrawals until The Merge is complete.
You're currently doing strtotime('$date $time')
. Variables wrapped in single-quotes aren't interpolated. If you use single-quotes, PHP will treat it as a literal string, and strototime()
will try to convert the string $date $time
into a timestamp.
It'll fail and that would explain why you're getting incorrect results.
You need to use double quotes instead:
$combinedDT = date('Y-m-d H:i:s', strtotime("$date $time")); ^ ^
And for those coming here working with DateTime objects:
$date = new DateTime('2017-03-14'); $time = new DateTime('13:37:42'); // Solution 1, merge objects to new object: $merge = new DateTime($date->format('Y-m-d') .' ' .$time->format('H:i:s')); echo $merge->format('Y-m-d H:i:s'); // Outputs '2017-03-14 13:37:42' // Solution 2, update date object with time object: $date->setTime($time->format('H'), $time->format('i'), $time->format('s')); echo $date->format('Y-m-d H:i:s'); // Outputs '2017-03-14 13:37:42'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With