Angular JS - YouTube timestamp to UNIX - angularjs

I'm trying to create an angular filter that converts my UNIX timestamp that I get from a datetimepicker to the YouTube formatted date and vice versa. I've searched everywhere but all I could find is a PHP function... Can someone provide assistance with this?
UNIX: 1440072453
YouTube: 2015-01-08T11:29:40.000Z

Example :
var d = new Date(Date.parse("2012-01-11T20:49:59.415Z"));
d.toString(); // => Wed Jan 11 2012 15:49:59 GMT-0500 (EST)
d.getTime(); // => 1326314999415
From Parsing a Youtube API Date in Javascript

Related

How to parse current date without the time?

I'm trying to set up the current time of a process but I just want to set up the day not the time/seconds like Tue, 28 Sep 2021.
I know 2 ways of doing dates and that would be:
new Date().toTimezoneString() and firebase.firestore.FieldValue.serverTimestamp() both of them includes time though.
and I know that if I set up Date() alone it store the data as a date format instead of a string.
Extra: can it be set up in other languages as well ?
Use Intl ( Internationalization API ) to format your dates. It's supported by all browsers and provides a comprehensive api to suit your date and time formatting needs.
Here is the doc for the method you need:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat
For your use-case where you dont want to show time, you simply do not pass timeStype in the options parameter to the Intl formatter. Example would be
const date = new Date();
const formattedDate = new Intl.DateTimeFormat('en-US', { dateStyle: 'medium' }).format(date)

How to download data from server using date in get methos React?

I'm new with React. I was looking for information for several days to no avail. So I decided to ask you my stupid question.
I have problem with transforming date from DatePicker to date format which than I can use in get request.
I use DatePicker from this https://www.npmjs.com/package/react-datepicker
Sample correct api call:
localhost:8080/api/measurement/12374?date=2020-12-13 12:00
but date from DatePicker look like:
Sun Dec 13 2020 12:00:00 GMT+0100 (Central European Standard Time)
I play with date for example:
let x = new Date();
let x1 = x.toLocaleDateString() + " " + x.toLocaleTimeString();
output: 23/12/2020 09:29:16
but still I have problem with date format and I also don't know how to pass this date correclty to get method, because http request have % instead "space"
http://localhost:8080/api/measurement/12120?date=23/12/2020%2009:48:15
but when I use string as date it work fine and download data:
let value = "12374";
let date = "2020-12-13 12:00";
const request = "http://localhost:8080/api/measurement/" + value + "?date=" + date;
Can someone explain me how can I convert date from DatePicker to format like this 2020-12-13 12:00 and then use it in get method?
I will be very grateful for any answer!
Thank you ;)
you can use momentjs for this task to format date.
https://www.npmjs.com/package/moment
import moment from 'moment'
let date = new Date();
let result = moment(date).format('DD/MM/YYYY hh:mm')
output: 23/12/2020 02:23

Dynamic form and date format in angularjs and node js

I hope you can help me I have some doubts about nodejs and angularjs, I'm just starting with this,
I am doing a project in nodejs with angularjs and I found this example of a project
Http://www.aorank.com/tutorial/angular_CRUD_demo/
my question
How can I do that to open another form within a same page as it does in the demo of the link? I hope you can explain me and my question is now about the format of the time, I am trying to get the date and now of this moment and for that use the following
Var datetime = require ('node-datetime');
Var date = Date.now ();
Var datenow = new Date (date);
Var date = datenow.toString ("dd-mm-yyyy HH: mm"). Replace (/ T /, '') .replace (/\..+/, '');
And the consula shows this as a result
Thu May 18 2017 12:17:59 GMT-0400 (CLT)
But I wish it was this way
2017-05-18 12:17:59
And the other doubt how I can make more dynamic and open a form inside another as in the demo link I leave, I hope you can help me and thank you for your time

AngularJS Date Time according to eastern time

I am using AngularJS to get date from service 2014-09-29 and time as 191042 .
I need to show something like this
29 September 2014 19:10:42 ET
How do I convert it according to eastern time zone as I am getting date & time separately?
You can format with a filter {{ date_expression | date : format : timezone}}, in your case: <span>{{datevar | date:'d MMMM y'}} {{timevar | date:'HH:mm:ss' : '-0500'}} ET</span> all the formats you find here: https://docs.angularjs.org/api/ng/filter/date. Check out at this plunker: https://plnkr.co/edit/l7ayOKSPGJp3Uvbfgtlx?p=preview. Completing the answer, if you need to ajust in summer time you can set the local with angular-locale plugin as you can see at this post: Angular JS - Date changes when submitting to $http - Timezone issue

Angular UI datepicker giving me a UTC converted string. How to parse it back to local time accounting for the time difference?

I am currently running into issues with datepicker automatically converting my time to UTC. Is there anything I can pass into datepicker for it to not give me back a UTC converted string? For example the user picks March 19 on the calendar and the returned string would be something like this
'2014-03-19T04:00:00.000Z'
What I want is ->
'2014-03-19T00:00:00-04:00'
What I am trying now (sort of hacking around it) is trying to use moment js to convert it back to my desired (expected) format, but I am having trouble doing so without hardcoding a subtraction in there. I want to be able to convert it from UTC back to local time.
Does anyone know of a solution to this using moment js or angular?
I ran into the same problem and used a filter that adjusts the date and time using the local data to get around it:
filter('adjustDatepicker', ['$filter', function($filter){
var dateFilter = $filter('date');
return function(dateToFix){
var localDate, localTime, localOffset, adjustedDate;
localDate = new Date(dateToFix);
localTime = localDate.getTime();
localOffset = localDate.getTimezoneOffset() * 60000;
adjustedDate = new Date(localTime + localOffset);
return dateFilter(adjustedDate, 'MM/dd/yyyy');
};
}])
Use it like this in your template file:
{{details.datetomodify | adjustDatepicker}}
I think new Date('2014-03-19T04:00:00.000Z').toString() will give you the local version of the UTC time.

Resources