Format of date printing it in input box - javascript

The input that am giving for my javascript function is
`Wed Jul 30 2014 11:34:00 GMT+0530 (India Standard Time)`
the fucntion that need to return this in to my needed fomat i.e
July 30 2014 11:34 AM
How can i achieve this?

Maybe Moment.js helps you?
Check this answer

Related

How to change date format in model of attribute in sails.js?

How we can set the date format of attribute in model from Tue Apr 12 2016 17:16:12 GMT+0530 (India Standard Time) to 2016-04-12 17:16:12?
I think this is what you need :
inputDate.format("isoDateTime");

Timezone offset causing wrong date

I'm using Bootstrap DatePicker's setEndDate function (Reference).
I need to pass to it a Javascript date object. I'm trying to convert a simple year-month-day string to a date, but depending on the windows' timezone, I get different results:
In GMT -8:
> new Date('2015-01-16')
=> Thu Jan 15 2015 16:00:00 GMT-0800 (Pacific Standard Time)
In GMT +2:
> new Date('2015-01-16')
=> Fri Jan 16 2015 02:00:00 GMT+0200 (Eastern Europe Standard Time)
So what I'm left with is a different end-date depending on what timezone the user is in, even though the server side provided the same date string.
I will appreciate help on the matter.
Apparently, even though the documentation states the function's argument should be a date object, it can in fact be given a string in a "m-d-yyyy" format.
So in my case all I had to do was call the function like this:
$('#my-input').datepicker('setEndDate', '1-16-2015');
Hope this helps someone.

Convert indian standard time to mysql datetime format using php

I have my indian standard time like ,
Wed Oct 08 2014 07:40:00 GMT 0530 (India Standard Time) , which is created by javascript,
Now i want to change this format to 2014-11-10 07:40:00 to store in mysql.
how can i do this.
I hope this will help you
$date = "Wed Oct 08 2014 07:40:00";
echo date('Y-m-d h:i:s',strtotime($date));
output
2014-10-08 07:40:00
You can use the moment.js library.
var a = "Wed Oct 08 2014 07:40:00 GMT 0530 (India Standard Time)";
var b = moment(a).zone(0).format(YYYY-MM-DD HH:mm:ss);
I personally would transform your time with the time()-function to the unix format amd with then with date() back to your liking:
http://php.net/manual/de/function.date.php
i.g.: date('Y-m-d H:i:s',time()) would give you the momentary time in the desired format.
edit: I forget the damn '...', but I corrected that. The accepted answer ist correct and a little bit better than mine.

Extract date from long complicated date plus time stamp?

I am using bootstrap calendar and on clicking any particular date I got complicated date in this form:
Sat Sep 06 2014 00:00:00 GMT 0500 (Pakistan Standard Time)
Can anybody please tell me how I can extract only date from this complicated long date?
I am working in PHP codeignitor, is there any way in PHP or JavaScript through which I can only extract date?
if this is for Javascript then just use this:
var myDate = new Date('Sat Sep 06 2014 00:00:00 GMT 0500 (Pakistan Standard Time)');
after that you can use myDate as a date object and call its methods like myDate.getFullYear() etc.

Date-time stamp conversion in javascript

I have Date String Thu May 23 2013 18:19:32 GMT+0530 (India Standard Time) from my database. I want to make in this format THURSDAY May 23 2013 18:19:32 GMT 0500 CDT in ext-js.any idea ? Thanks in advance.
There are 2 excellent ate parsing libraries available tat you can use. They are both very small
https://code.google.com/p/datejs/
http://momentjs.com/
Sample datejs usage:
Date.parse('Thu, 1 July 2004 22:30:00 GMT') // Thu Jul 01 2004 16:30:00
You can then format the date object in whatever format you require for output.

Categories

Resources