Convert GMT date format to only time format

Vinit Desai

I am building an html application using AngularJS wherein I want to display the json file data on html page. Can anyone help me to Convert GMT date format from json file to hour:minutes AM/PM

Json file looks like this:

[
    {
        "startTime": "Sun May 24 2015 01:00:00 GMT+0530 (IST)",
        "endTime": "Sun May 24 2015 01:30:00 GMT+0530 (IST)",
        "title": "Event 1"
    },
    {
        "startTime": "Sun May 24 2015 04:00:00 GMT+0530 (IST)",
        "endTime": "Sun May 24 2015 06:00:00 GMT+0530 (IST)",
        "title": "Event 2"
    },
    {
        "startTime": "Sat May 23 2015 20:00:00 GMT+0530 (IST)",
        "endTime": "Sat May 23 2015 21:30:00 GMT+0530 (IST)",
        "title": "Event 3"
    },
    {
        "startTime": "Sat May 23 2015 21:30:00 GMT+0530 (IST)",
        "endTime": "Sat May 23 2015 22:15:00 GMT+0530 (IST)",
        "title": "Event 4"
    },
    {
        "startTime": "Sun May 24 2015 02:00:00 GMT+0530 (IST)",
        "endTime": "Sun May 24 2015 03:00:00 GMT+0530 (IST)",
        "title": "Event 5"
    }
]
Bharath

The link provided by @worldask says

Date to format either as Date object, milliseconds (string or number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is specified in the string input, the time is considered to be in the local timezone.

So I am using a custom filter for converting Sun May 24 2015 01:00:00 GMT+0530 (IST) to milliseconds and then using angular filter to show as hh:mm AM/PM

HTML

<div ng-repeat="date in dateJson">
      {{date.startTime | myDateFilter | date:'hh: mm a' }}
</div>

dateJson is your sample json...

custom filter

app.filter('myDateFilter', function() {

  return function(dateString) {
    var date = new Date(dateString)

    // converting to milliseconds
    dateString = date.getTime();
    return dateString;
  }
});

SAMPLE PLUNKER

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Convert miliseconds to date and time and format by locale

分類Dev

convert text string to date/time format

分類Dev

PHP - Convert this string to another date/time format

分類Dev

how to convert python time.time() to date format for sql insertion

分類Dev

How to format the given time string and convert to date/time object

分類Dev

Date Format Convert

分類Dev

Date Format Convert

分類Dev

convert date format in log

分類Dev

Convert time format in PHP

分類Dev

What is this date and time format?

分類Dev

String date format convert to date

分類Dev

Convert London Time & Date To GMT +6 Time & Date

分類Dev

How can I convert date time format string used by C# to the format used by moment.js?

分類Dev

Convert Date String in Format "Mon Day, Year Time am/pm" to POSIXlt format in R?

分類Dev

Convert date format to string in Pandas

分類Dev

How to convert date into given format?

分類Dev

Excel text to convert date format

分類Dev

How to convert date format in JavaScript?

分類Dev

Parse Date and Time in specific format

分類Dev

Convert date to format Day, date month year

分類Dev

pandas date-time format VS google sheets date format

分類Dev

Convert utc time into local time of specifc format

分類Dev

What is this date time format? How to convert it into a human readable output? Why it returns this output?

分類Dev

How do I convert API supplied date/time string into readable format?

分類Dev

How to change json string of date and format it to only show the day without, year, month, or time

分類Dev

convert 12 hour format to 24 hour format time in golang

分類Dev

How can I format date_space_hour to a time format

分類Dev

Parse UTC date string and convert to different format

分類Dev

Convert date from human readable format golang

Related 関連記事

  1. 1

    Convert miliseconds to date and time and format by locale

  2. 2

    convert text string to date/time format

  3. 3

    PHP - Convert this string to another date/time format

  4. 4

    how to convert python time.time() to date format for sql insertion

  5. 5

    How to format the given time string and convert to date/time object

  6. 6

    Date Format Convert

  7. 7

    Date Format Convert

  8. 8

    convert date format in log

  9. 9

    Convert time format in PHP

  10. 10

    What is this date and time format?

  11. 11

    String date format convert to date

  12. 12

    Convert London Time & Date To GMT +6 Time & Date

  13. 13

    How can I convert date time format string used by C# to the format used by moment.js?

  14. 14

    Convert Date String in Format "Mon Day, Year Time am/pm" to POSIXlt format in R?

  15. 15

    Convert date format to string in Pandas

  16. 16

    How to convert date into given format?

  17. 17

    Excel text to convert date format

  18. 18

    How to convert date format in JavaScript?

  19. 19

    Parse Date and Time in specific format

  20. 20

    Convert date to format Day, date month year

  21. 21

    pandas date-time format VS google sheets date format

  22. 22

    Convert utc time into local time of specifc format

  23. 23

    What is this date time format? How to convert it into a human readable output? Why it returns this output?

  24. 24

    How do I convert API supplied date/time string into readable format?

  25. 25

    How to change json string of date and format it to only show the day without, year, month, or time

  26. 26

    convert 12 hour format to 24 hour format time in golang

  27. 27

    How can I format date_space_hour to a time format

  28. 28

    Parse UTC date string and convert to different format

  29. 29

    Convert date from human readable format golang

ホットタグ

アーカイブ