Comments (1)
Not what I expected at first:
$micro = 254687;
$first = Carbon::createFromFormat('Y-m-d H:i:s.u', '2014-02-01 03:45:27.'.$micro);
$micro = 254688;
$second = Carbon::createFromFormat('Y-m-d H:i:s.u', '2014-02-01 03:45:27.'.$micro);
$floatFirst = (float)($first->format('U.u'));
$floatSecond = (float)($second->format('U.u'));
var_dump($floatFirst);
var_dump($floatSecond);
var_dump($floatSecond - $floatFirst);
float(1391244327.2547)
float(1391244327.2547)
float(9.5367431640625E-7)
I think it would have to take this approach:
$firstMicro = $first->micro;
$secondMicro = $second->micro;
var_dump($firstMicro);
var_dump($secondMicro);
var_dump($secondMicro - $firstMicro);
var_dump(($secondMicro - $firstMicro)/1000000);
$diff = $second->diffInSeconds($first) + (($secondMicro - $firstMicro)/1000000);
var_dump($diff);
int(254687)
int(254688)
int(1)
float(1.0E-6)
float(1.0E-6)
from carbon.
Related Issues (20)
- Both Hong Kong and Macao are the Special Administrative Regions of China HOT 5
- isSameUnit not working like in previous versions and accepting "null" as argument HOT 8
- createFromTimestamp does not respect the default timezone HOT 4
- Can no longer use `createFromFormat` with an non-string value as time input HOT 5
- Error addRealSeconds HOT 4
- The output of diffInMonths is indeed incorrect HOT 1
- Carbon v3 diffInDays is not consistent HOT 3
- [Translation tool] bn_BD HOT 1
- Unable to add unit array error since updating to v3 HOT 3
- Feature request: auto convet to int on diffIn* methods HOT 3
- Daylight Savings for Europe/Dublin is incorrect HOT 4
- Incorrect totalSeconds after adding interval to CarbonInterval in v3 HOT 1
- Period `start` and `end` always wrong with Carbon 3 HOT 3
- Carbon ->toPeriod with interval / duration string fails after 3.2.1 version HOT 1
- Carbon v3 Documentaion for diffIn* methods HOT 2
- More granular v2 to v3 upgrade documentation? HOT 3
- [Translation tool] bs HOT 2
- diffForHumans() gives incorrect wording for SLOVAK language HOT 1
- Type error when calling canBeCreatedFromFormat with null date HOT 3
- diffInDays returns a float HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carbon.