-2

This is my You tube url

https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=fS7w-TXinPE&key=AIzaSyC4lRjR4DGfL2l0VmBRvd1QcWr_lLlPIj0

It returns this response:

{
  kind: "youtube#videoListResponse",
  etag: ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/w7nxpQxTlGkdBoZPAIBIF2cALdw"",
  pageInfo: {
    totalResults: 1,
    resultsPerPage: 1
  },  
  items: [
    {
      kind: "youtube#video",
      etag: ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/p0zloVjCNWVokJq4rLGkLn80h0I"",
      id: "fS7w-TXinPE",
      contentDetails: {
        duration: "PT1H38M24S", # <--
        dimension: "2d",
        definition: "sd",
        caption: "false",
        licensedContent: true
      } 
    }
  ]
}

What is this format, and how to change that the duration in india time??

AD7six
  • 63,116
  • 12
  • 91
  • 123
RAMAR T
  • 7
  • 4
  • You know what, I'm flagging this as spam because: 1. your URL does not contain anything having to do with the string "PT1H38M24S" in the title, and 2. durations do not have a time zone, so changing "that the duration in india time"[SIC] is meaningless. Therefore the only purpose of this "question" must be to promote your video, whatever it may be about. – lc. Aug 20 '15 at 08:49
  • 2
    Though i would also say that this question is not written very well (what is the intention of the question), I wouldn't mark it as spam, since the url points to a REST-resource at googleapis.com and in the JSON document that lies behind the URL there is a field "duration" with the string "PT1H38M24S". Nevertheless, RAMAR T should definitely improve his question. – Marcus Gründler Aug 20 '15 at 08:56
  • i need to change that duration: "PT1H38M24S" to 1:38:24 – RAMAR T Aug 20 '15 at 09:00
  • 5
    possible duplicate of [Convert youtube Api v3 video duration in php](http://stackoverflow.com/questions/24393230/convert-youtube-api-v3-video-duration-in-php) also see [other duplicates](http://stackoverflow.com/questions/19562195/converting-youtube-data-api-v3-video-duration-format-to-standard-time-in-php). – AD7six Aug 20 '15 at 09:03
  • Read the funky manual! – hek2mgl Aug 20 '15 at 09:27

1 Answers1

3

It's an ISO 8601 Date Interval

Use PHP's DateInterval class

$dateInterval = new DateInterval("PT1H38M24S");
echo $dateInterval->h .':' . $dateInterval->i . ':' . $dateInterval->s;

Demo

But 1 hour 38 minutes and 24 seconds is the same duration wherever you are; durations aren't like timezones. India doesn't have its own time durations.

Mark Baker
  • 209,507
  • 32
  • 346
  • 385