Thats my json string or part of it: "/Date(1423232459000)/"  I do  var date= $.parseJSON(item.createdAt);  but an error is thrown in the console:  Uncaught SyntaxError: Unexpected token /   How can I fix that or read the date?
446
I'm taking my first crack at  with jQuery. I'm getting my data onto my page, but I'm having some trouble with the JSON data that is returned for Date data types. Basically, I'm getting a string back that looks like this:  /Date(1224043200000)/   From someone totally new to JSON - How do I format this to a short date format? Should this be handled somewhere in the jQuery code? I've tried the jQuery.UI.datepicker plugin using $.datepicker.formatDate() without any success.  FYI: Here's the solution I came up with using a combination of the answers here:  function getMismatch(id) {   $.getJSON("Main.aspx?Callback=GetMismatch",     { MismatchId: id },      function (result) {       $("#AuthMerchId").text(result.AuthorizationMerchantId);       $("#SttlMerchId").text(result.SettlementMerchantId);       $("#CreateDate").text(formatJSONDate(Date(result.AppendDts)));       $("#ExpireDate").text(formatJSONDate(Date(result.ExpiresDts)));       $("#LastUpdate").text(formatJSONDate(Date(result.LastUpdateDts)));       $("#LastUpdatedBy").text(result.LastUpdateNt);       $("#ProcessIn").text(result.ProcessIn);     }   );    return false; }  function formatJSONDate(jsonDate) {   var newDate = dateFormat(jsonDate, "mm/dd/yyyy");   return newDate; }   This solution got my object from the callback method and displayed the dates on the page properly using the date format library.
58463
Does anyone know of an easy way to escape HTML from strings in ?  I need to be able to pass an arbitrary string and have it properly escaped for display in an HTML page (preventing JavaScript/HTML injection attacks).  I'm sure it's possible to extend jQuery to do this, but I don't know enough about the framework at the moment to accomplish this.
111221
I have a custom meta box with a datepicker. The datepicker outputs 2013-01-17 10:00 in my database for an event that is 01-17-2013 at 10pm PST.  $eventlist = new WP_Query(array(     'post_type' =&gt; 'events',     'posts_per_page' =&gt; 5,     'order' =&gt; 'asc',     'orderby' =&gt; 'meta_value',     'meta_key' =&gt; 'datetime',     'meta_query' =&gt; array(         array(             'key' =&gt; 'datetime', // Check the start date field             'value' =&gt; date("Y-m-d H:i:s"),               'compare' =&gt; '&gt;=',              'type' =&gt; 'DATETIME'          )     ), ));   The issue is, at 4pm PST the event disappears, leading me to believe somewhere it is thinking its UTC and making the post go bye bye. Where would i Find this issue and how can i solve it?
57923
I wanted to use this, but I don't know if it's actually valid in English:     The specified date is invalid.It points to a non-existing day.   I'm not a native speaker, and I just want to say that the input points to a date that does not exist, like 30th February.
116296
Anytime I have to handle dates/times in java it makes me sad   I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.  "Exception in thread "main" java.lang.Error: Unresolved compilation problem:  The method setDate(int, Date) in the type PreparedStatement is not applicable for the arguments (int, Date)"  Eh WTF?  Here is the offending code.  for(int i = 0; i &lt; flights.size(); i++){      String[] details = flight[i].toString().split(":");      DateFormat formatter ;      formatter = new SimpleDateFormat("ddMMyyyy");     Date date = formatter.parse(details[1]);       PreparedStatement pstmt = conn.prepareStatement(insertsql);     pstmt.setString(1, details[0]);     pstmt.setDate(2, date);     pstmt.setString(3, details[2] + "00");     pstmt.setString(4, details[3]);     pstmt.setString(5, details[4]);     pstmt.setString(6, details[5]);     pstmt.setString(7, details[6]);     pstmt.setString(8, details[7]);     pstmt.setString(9, details[8]);     pstmt.executeUpdate();  }
9505
Let me explain you the problem   $ date +%c -d "$d" Tue 31 Dec 2013 01:13:06 PM CET $ date +'Today is %F' -d "$d" Today is 2013-12-31   This solution corresponds to current date.  But I have one variable which stores date other than current date  $Prev_date="Wed Dec 25 06:35:02 EST 2013"    I am looking for solution to read this date as 2013-12-25 and store it in a variable.  I have tried this:  a=`date --date=$Prev_date '+%y/%m/d'` echo $a   It's giving this error:  date: illegal option -- date=Wed usage: date [-u] mmddHHMM[[cc]yy][.SS] date [-u] [+format] date -a [-]sss[.fff]
58885
Given   A JSON string with Apex reserved words (like "currency":"USD" and otherwise undeserializable-into-Date type (like "someDate":"0001-01-01T00:00:00Z" ) An apex method that uses   String s = s.replaceAll('"currency":','"currencyX":')             .replaceAll('"0001\\-01\\-01T00:00:00Z"','null');    before deserializing into a custom Apex type with property String currencyX and Date someDate  When  The incoming Apex string is very large (> 1MB)  Then  Uncatchable error: Regex Too Complicated     What to do?
89206
I am getting error:     The argument 2 of the "JSON_VALUE or JSON_QUERY" must be a string literal   ...while trying to pass variable as parameter to JSON_QUERY function. Please help me to resolve it.  DECLARE @cnt INT = 1; DECLARE @cnt_total INT = 1; DECLARE @json NVARCHAR(MAX); DECLARE @json1 NVARCHAR(MAX); declare @str  VARCHAR(200);  WHILE @cnt &lt;= 10 BEGIN     set @str = '$.Seasons[0].Products['+convert(varchar,@cnt)+'].ProductChannels';     set @str = char(39) +@str+ char(39);     PRINT @STR     select @json = json_query(jfile,@STR) from Import.tstjson; --MORE CODE         SET @cnt = @cnt + 1; END   Sample data:  {   "Seasons": [     {       "Season": "12321231",       "Products": [         {           "ProductId": "211",           "ProductChannels": [             {               "ChannelId": 1,               "WeekQuantities": []             }           ],           "ccc": 3,           "Tttt": 4         }       ]     }   ] }
492
I have a web page with three dropdowns for day, month and year. If I use the JavaScript Date constructor that takes numbers, then I get a Date object for my current timezone:  new Date(xiYear, xiMonth, xiDate)   Give the correct date, but it thinks that date is GMT+01:00 due to daylight savings time.  The problem here is that I then pass this Date to an Ajax method and when the date is deserialised on the server it has been converted to GMT and so lost an hour which moves the day back by one. Now I could just pass the day, month, and year individually into the Ajax method, but it seems that there ought to be a better way.  The accepted answer pointed me in the right direction, however just using setUTCHours() by itself changed:  Apr 5th 00:00 GMT+01:00    to  Apr 4th 23:00 GMT+01:00   I then also had to set the UTC date, month and year to end up with  Apr 5th 01:00 GMT+01:00   which is what I wanted.
25978
Presently the date is showing as mmm dd hh:mm:ss. Is there any way that I can change it to as per my liking. For example : dd mmm, hh:mm:ss.
7837
Is DOM the only way to parse JSON?
62499
I Have a string that is equal to a date, represented as the number of milliseconds since the Unix epoch.  I am trying to output it into d-m-Y.  The string I was given was "1227643821310", and I am told that the result should be equal to 2-12-2008, but I keep getting a result of 25-11-2008  My code is as follows:  $mil = 1227643821310; $seconds = $mil / 1000; echo date("d-m-Y", $seconds);   Any ideas as to why this might be?
88507
I have a string as,  field name : start Date: 2016-11-14 08:00 AM ( string type)  how to convert this to Date time. I tried Date.parseDate and below option also.  String val = recruiters[j].Start_Time_Formula__c;                              system.debug('val ::'+ val);                             DateTime date1 = (DateTime)Json.deserialize('"'+val+'"', DateTime.class);                             system.debug('date1 ::' + date1);   but I am getting error as,     System.JSONException: Invalid format: "2016-11-14 08:00 AM" is malformed at " 08:00 AM": (System Code)   I referred the below link and got with the above error.    any help ?
90240
I have the below code:  public class CallOutForGet {      HttpRequest request=new Httprequest(); http http=new http(); request.setEndPoint('https://th-apex-http-callout.herokuapp.com/animals'); request.setmethod('GET');  HttpResponse response=http.send(request);  if(response.getStatusCode()==200){      Map&lt;String,Object&gt; results= (Map&lt;String,Object&gt;)JSON.deserializeUntyped(response.getBody());      List&lt;object&gt; animals=(List&lt;object&gt;)results.get('animals');     System.debug('Received Animals************');     for(object anim:animals){         System.debug(anim);     } }  }   This error at line -  request.setEndPoint('https://th-apex-http-callout.herokuapp.com/animals');  says expecting right parenthesis.
2361
Given a string of JSON data, how can I safely turn that string into a JavaScript object?  Obviously I can do this unsafely with something like:  var obj = eval("(" + json + ')');   but that leaves me vulnerable to the JSON string containing other code, which it seems very dangerous to simply eval.
102155
Background When a date is to be shown that is from this year it is shown as &quot;Mar 12&quot; for the &quot;12th of March&quot; rather than &quot;Mar 12 '14&quot;. While the full form is not what I'm used to (as a European) it is at least unambiguous. However &quot;Mar 12&quot; reads as &quot;March 2012&quot; to me and confuses me every time. Although I have (after months of pain) stopped misreading it I still feel the Parse Error: Needs Stack Exchange Mode and the slight pause as my brain tried to reparse it. The most recent example of someone confused by this is here . I was myself caught by this . Feature request Even for recent dates; once the date is shown at all show the full date including the year. So this post was posted on Mar 22 '14. This seems to have no downsides as it takes no extra space (there needs to be space for the long form anyway) and is much clearer to those of us who don't use an American date system.
85197
I have a complex JSON object which is sent to the View without any issues (as shown below) but I cannot work out how Serialize this data back to a .NET object when it is passed back to the controller through an AJAX call. Details of the various parts are below.     var ObjectA = {         "Name": 1,         "Starting": new Date(1221644506800),          "Timeline": [             {                 "StartTime": new Date(1221644506800),                 "GoesFor": 200              }             ,             {                 "StartTime": new Date(1221644506800),                 "GoesFor": 100              }          ]     };   I am not sure how this object can be passed to a Controller Method, I have this method below where the Timelines object mirrors the above JS object using Properties.  public JsonResult Save(Timelines person)   The jQuery I am using is:          var encoded = $.toJSON(SessionSchedule);          $.ajax({             url: "/Timeline/Save",             type: "POST",             dataType: 'json',             data: encoded,             contentType: "application/json; charset=utf-8",             beforeSend: function() { $("#saveStatus").html("Saving").show(); },             success: function(result) {                 alert(result.Result);                 $("#saveStatus").html(result.Result).show();             }         });   I have seen this question which is similar, but not quite the same as I am not using a forms to manipulate the data.   I have also seen references to using a 'JsonFilter' to manually deserialize the JSON, but was wondering if there is a way to do it nativly though ASP.NET MVC? Or what are the best practices for passing data in this way?