Question: I want to plot correlation matrix in such a sense that it should be interactive and show both, correlation values and corresponding p-values in ggplot2 or plot\_ly.

I have tried the following code.

```
    library(ggplot2)
    library(plotly)
    library(reshape)
    library(Hmisc)

    x <- Seatbelts
    y <- as.matrix(x)
    rt <- rcorr(y)
    mtlr <- melt(rt$r)
    mtlp <- melt(rt$P) 
    gx <- ggplot(mtl, aes(X1, X2, fill = value)) + geom_tile() + 
      scale_fill_gradient(low = "cyan",  high = "red")
    ggplotly(gx)

```

I want to show "mtlp" value in the same plot.

Can anyone help?

Answer: 
Please try this:

```
let dateString = "2017-12-01 10:00:00 +0000"

print("original date = \(dateString)")

var formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z"
formatter.timeZone = TimeZone.init(abbreviation: "UTC")

if let date = formatter.date(from: dateString) {
    formatter.timeZone = TimeZone(identifier: "Asia/Shanghai")
    let localTime = formatter.string(from: date)
    print(localTime)
}
print("test")

```

Output: 

```
original date = 2017-12-01 10:00:00 +0000
2017-12-01 18:00:00 +0800
test

```
GMT: 
`formatter.timeZone = TimeZone(abbreviation: NSTimeZone.local.abbreviation()!)` 

UTC:
`formatter.timeZone = TimeZone(abbreviation: NSTimeZone.default.abbreviation()!)`

To display local datetime, i use the GMTTimeZone.