RAHUL DEEP
RAHUL DEEP

Reputation: 655

Converting local time into UTC time in angularjs

I am using var

date= new Date();

in my controller to get current local time. I am getting the output like this-

var date=Mon Aug 03 2015 07:56:55 GMT +0530(India Standard Time)

but i need UTC time. How to get UTC time in angularjs or convert local time into UTC time.

Upvotes: 2

Views: 7401

Answers (3)

Shohel
Shohel

Reputation: 3934

using moment.js you can convert the local date to UTC date easily.

Syntax

moment.utc(Date); 

Moment DOCS

Upvotes: 0

RAHUL DEEP
RAHUL DEEP

Reputation: 655

var date=new Date();    //will give local time
var date1=date..toUTCString();      //will give 

Upvotes: 1

link
link

Reputation: 2510

use date.toISOString()

Hope this helps.

Upvotes: 0

Related Questions