I use momentjs inside angular js and I acount the duration in seconds and I can format it in HH:mm format as 03:35 but I cannot find in documentaion and google to how show it in format 3h 35m could anybody point me to right documentation???
This should get what you're after:
moment().format("H[h] mm[m]");
Take a look at Format from the momement.js docs. The [] is used to escape characters in format strings.
Related
I want to convert Date into String format. First I want to get Date from react-datePicker and only want to convert it into single String UTC to String format "22-10-2020"
On your onChange event, you can get e.target.value and use like it new Date(e.target.value).toISOString().split('T')
if you want to convert the Date into string format then use toLocaleDateString() with the date i.e new Date().toLocaleDateString(); // 26-11-2020. <- string
You can Do This Things with use of Moment
, You can Easyly switch you format and also play with date and time type. Moment js is Easy Way to play with such thing .
var viewValue = "GMT";
return moment(moment().tz(viewValue).format('LLL'));
Above return throw below error, can you please let me know how to fix below issue:
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
The statement moment().tz('GMT').format('LLL') results in a string like this:
May 3, 2018 7:29 AM
The above string is not in a valid ISO format. That's why you receive this warning because if you pass this to the moment constructor, you're creating a MomentJS object again.
To mitigate, you need to specify the format of the string to parse it correctly:
moment(moment().tz('GMT').format('LLL'), 'MMM DD, YYYY HH:mm A');
As warning clearly shows that returned value (Date format) from your code is not supported by momentjs. This format is deprecated and will be removed in future.
So solution for this is to choose any of the format from below link:
Check Supported ISO 8601 strings & The RFC 2822 date time format here http://momentjs.com/docs/#/parsing/string/
I have a string with a full date like this: "2016/03/05 13:47:18 +0000".
I want covert it to "2016-03-05" or "05-March-2016" on Angular scope. I also have integer time duration = 421471 which I want to convert to a time format like "23:45" or "1 hour , 50 minute".
{{sound.created_at | date}}
{{sound.duration}}
How can I do that?
To solve your issue please use momentjs as very famous lib to deal everything about date in js.
To make it work well with Angularjs/4, please have a look here.
this the time format i need to convert with angular, in the format each has its own timezone(at the end starts with +) and i want to filter with related to their timezone.
"2016-09-01T11:15:00.000+01:00"
"2016-09-01T21:50:00.000+03:00"
"2016-09-02T07:30:00.000+05:00"
what i tried to do was returning me my browser timezone:
{{o.ArrivalTime | date:'dd MMMM HH:mm'}}
o.arrivaltime is what that gives me the above time stamp.
I'm using the CakeTime class for my localization of dates & times.
For dates it works like I want it to:
$timestring = $this->Time->format('Y-m-d H:i:s', time());
echo 'DateTime: '.$this->Time->i18nFormat($timestring);
// Result => DateTime: 11/08/2013
I want it to also display the time.
For example in the US they use AM/PM and in other places they use the 24 hour notation.
I've looked but can't seem to find a way to do this.
Any idea's?
Edit*
To be clear, the localization works perfectly for the dates(have the LC_TIME files), but the i18nFormat function only returns the date, and from what i saw, passing a format will use that format, not the localized one, example MM/DD/YYYY vs DD.MM.YYYY in a different locale
*Edit2:
The solution vicocamacho gave in the comments is the correct one
So to get the Date + Time in the localized form:
$this->Time->i18nFormat(time(), '%x %X') does the trick!
You can use the TimeHelper::i18nFormat method. You also can check this repo to find common date/time translations https://github.com/cakephp/localized be sure to store them in the APP/locale/<locale>/LC_TIMEdirectory