Angular moment date with GMT date time - angularjs

Hi i'm working with angular with moment API in GMT timezone.
form
$scope.criteria.fromDate = $scope.criteria.fromDate || moment().startOf('day').hour(moment().hour()).minute(moment().minute()).second(moment().second()).toDate();
to
$scope.criteria.toDate = $scope.criteria.toDate || moment().startOf('day').hour(moment().hour()).minute(moment().minute()).second(moment().second()).toDate();
when I console the from date I got "FROM_DATE" -> "Wed Aug 30 18:30:00 UTC 2017" and to date is Wed Aug 30 18:30:00 UTC 2017
from date is a date with day start time and to date is a date with end day time . that's what i want.

Related

how to return the right date using date picker react

when i select date 06/11/2022
Datepicker shows 06/11/2022
Console.log shows Sun Nov 06 2022 00:00:00 GMT+0100 (heure normale d’Europe centrale)
I want to get just Date remouving time by using
date.toISOString().split('T')[0] ==> 05/11/2022
what can i do to get the right date?
Thnaks

Converting Date in Snowflake

I have a Snowflake Stored Proc that uses Run_Date as a parameter. With the the code when I use the this date I get Tue May 03 2022 08:37:42 GMT-0500 (Central Daylight Time).
How can I convert this date to something like this - 2022-01-15 10:20:33.001 +0000

new Date() always returns local date....how to get Date object in utc?

I retrieve UTC date string from backend in form: 2020-02-16T22:00:00Z
To use new version of react-datepicker, dates should be converted into JS Date object (because it doesn't work with moment anymore)....otherwise datepicker throws Invalid date error.
So, before passing date to datepicker's selected prop, I must do this:
let date = new Date(utcDateStringFromBackend) but then, date becomes local, CEST date object (in my case +1h hour): Sun Feb 16 2020 23:00:00 GMT+0100 (Central European Standard Time)
How to get js Date object in UTC?
You can try something like this. If you want to get the date in UTC.
let date = "Sun Feb 16 2020 23:00:00 GMT+0100"
console.log(new Date(date).toUTCString())
outputs Sun, 16 Feb 2020 22:00:00 GMT
new Date(new Date().toUTCString()).toISOString()

AngularJS change date format( JUN, Wednesday ) from Wed Jun 08 2016 05:30:00 GMT+0530 (India Standard Time)

I want to change date format from Wed Jun 08 2016 05:30:00 GMT+0530 (India Standard Time) to JUN, Wednesday.
I have tried, <p data-ng-bind = "'Wed Jun 08 2016 05:30:00 GMT+0530 (India Standard Time)'| date:'MMM' "></p>
I did not get the exact result(JUN, Wednesday), please help.
Your problem is you're trying to cast a string with date format. So, You need to cast first string to date, then move the hour for the timezone problem, finally apply the filter.
In your controller you must do something like:
# Step 0: Get a date from your string
var date = new Date('Wed Jun 08 2016 05:30:00 GMT+0530');
# Step 1: From the date move, for the Timezones problems.
$scope.date = new Date(date.valueOf() + date.getTimezoneOffset() * 60000);`
Then, in your view you can use {{ date | date:'MMM-EEEE' }}
You can check in this Plnkr: http://plnkr.co/edit/zselhzgL4njIWEXxTWh6?p=preview

Convert Date: Day Mon YYYY hh:mm AM CET

I have these dates, that I need converted to date:
Sat Nov 22 2014 01:01 AM CET
Mon Aug 18 2014 06:32 PM CEST
All the convert or cast functions I tried didn't work, maybe someone has an idea what to do?
In the end, I would need something like
YYYY-MM-DD HH:MM:SS or DD.MM.YYYY HH:MM:SS that doesn't really matter, but I would need them in the same timezone if at all possible...
Thank You for any ideas
SQL Server can convert that if you get rid of the day of the week at the beginning and the time zone at the end:
SELECT CONVERT(DATETIME, SUBSTRING('Sat Nov 22 2014 01:01 AM CET',4,LEN('Sat Nov 22 2014 01:01 AM CET')-7))
SELECT CONVERT(DATETIME, SUBSTRING('Mon Aug 18 2014 06:32 PM CEST',4,LEN('Mon Aug 18 2014 06:32 PM CEST')-7))
I'm not sure what you mean that you need them in the same time zone.

Resources