Login
Remember
Register
PHPOnlineSupport
Questions
Unanswered
Tags
Categories
Ask a Question
Ask a Question
Day.js date difference not working
0
votes
1.1k
views
asked
Jan 26, 2022
in
Javascript
by
Sampath
Day.js date difference not working.
Im not sure what I'm doing wrong here?
var date1 = dayjs(field_data).format('D MMM YYYY');
var date2 = dayjs().format('D MMM YYYY');
var diff = date1.diff(date2, 'day');
alert(diff);
date1 and date2 are alerting properly. But the diff just dont work.
date
difference
day
js
Your comment on this question:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
1
Answer
0
votes
answered
Jan 26, 2022
by
Saju
In my experience, the day difference with format will not work. Its the same with moment.js and Day.js
Try this
var date1 = dayjs(field_data);
var date2 = dayjs();
var diff = date1.diff(date2, 'day');
alert(diff);
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Related questions
0
votes
1
answer
1.0k
views
How to format date and time in Day.js
asked
Jan 26, 2022
in
General
by
Jithu
day
js
date
time
format
0
votes
1
answer
860
views
Getting Current date, time , day in laravel
asked
Jun 3, 2021
in
Laravel
by
Nitha
laravel
date
0
votes
1
answer
17.0k
views
Find all active links on a page with JS (not hashed '#')
asked
Jul 25, 2018
in
Jquery
by
Jennifer
hashed
links
jquery
js
0
votes
1
answer
968
views
Find difference between two dates
asked
Jan 26, 2022
in
Jquery
by
Singer
library
date
+1
vote
0
answers
1.3k
views
load js files dynamically on the fly
asked
Oct 17, 2016
in
Laravel
by
Siva
laravel
include
dynamic
js
javascript
0
votes
1
answer
1.8k
views
Check where the current time is between a given time limit or not - PHP
asked
May 19, 2016
in
General
by
Mike
php
date
All categories
General
(56)
CMS
(21)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Jquery
(7)
Databases
(5)
Categories
All categories
General
(56)
CMS
(21)
Frameworks
(21)
eCommerce
(58)
IOT - Internet Of Things
(10)
Javascript
(10)
Jquery
(7)
Databases
(5)
Most popular tags
magento
php
wordpress
wp
laravel
category
database
module
product
arduino
kohana
js
jquery
admin
date
url
sing
birds
json
javascript
cms
cache
error
configurable
love
mac
xbee
serial1
serial
seo
encrypt
recaptha
phalcon
truncate
fishpig
include
backend
function
email
plugin
post
arduinojson
popup
mongodb
security
migrate
editor
decrypt
python
iot
map
shipping
password
core
log
mage
pear
string
replace
extension
import
php7
form
order
day
google
image
youtube
https
http
customer
syntaxerror
datatables
nested
x-ctu
xctu
pan-id
mesh
coordinator
esp
baud
esp8266
esp32
path-issue
site-links
adblocker
qr-code
barcode
samsung
newsletter
feed
auto-numbering-column
datatable
admin-bar
adminbar
toolbar
address16
address64
301
302
...