Changing the timestamp format in the last modified section of a Wikipedia page

Using various API client codes, I have implemented mediawiki-js to retrieve the last modified date of Wikipedia pages. While consulting the MediaWiki API documentation, I came across different timestamp formats but struggled to find the correct syntax to apply it. The provided code snippet:

var mwjs = new MediaWikiJS('https://en.wikipedia.org', { action: 'query', prop: 'revisions', titles: 'Main_Page' }, function (data) {
        'use strict';
        var pages = data.query.pages;
        alert('Main page of Wikipedia last edited by: ' + pages[Object.keys(pages)[0]].revisions[0].timestamp);
    });

displays the default format. How can I modify it to display a different required format?

Answer №1

It appears that the date formats provided in the links are intended for specifying input to the API, not for formatting the output received from the API.

To display the date in a different format for the user, utilize the date parsing and formatting capabilities of your programming language.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular ng-repeat allows for dynamically generating elements based on a collection in AngularJS

I recently started using the angular-scrolltofixed plugin and so far, it's been working really well for me. However, I've run into a problem when trying to set limitations for the bottom bar. $('.footer').scrollToFixed( { bottom: 0, ...

Can I bypass an invalid SSL certificate when making a request using a JavaScript library?

Is it possible to bypass invalid SSL certificates when using the widely-used request library? You can find more information about the library here: https://www.npmjs.com/package/request I am currently integrating this library into a Node.js server to send ...

How to Use AJAX to Read a Text File in JavaScript

Having trouble with AJAX! I have successfully set up a marquee on my website, but now I want it to dynamically fetch the text from a text file. The goal is to read the text from the file (which contains only one line) and assign it to a global variable nam ...

What is the best way to ensure an observable has finished before retrieving a value?

Looking at the function provided below: public getAssemblyTree(id: number) { .... const request = from(fetch(targetUrl.toString(), { headers: { 'responseType': 'json' }, method: 'GET' })); request.sub ...

Starting a Node server by running a JavaScript file on server startup

I have a piece of Node.js code (scheduler and a few database queries) that I need to run every time the Express app is started on the node server. One possible solution I thought of is creating a batch file with two lines: one to start the node server an ...

Ways to identify the moment jQuery datatable is initialized and populated with information

I am currently using the most recent version of jQuery datatables. I'm curious if there is a callback function available that triggers right after the data has been loaded and displayed in the table? While experimenting with a datatable in IE8, I hav ...

Having trouble retrieving the response from Jquery ajax with ajaxoptions

Struggling to utilize jQuery effectively. function fetchData(Id) { var ajaxOptions = { url: 'Api/Client/Get?Id=' + id, type: 'GET', dataType: 'json' }; return $.ajax(ajaxOptions).done().fa ...

What is the best way to synchronize the image dimensions and source when dynamically loading images?

I am facing an issue with a function that updates images by altering the src and css (width/height) of an IMG tag within the document. Below is a simplified example to demonstrate the problem: updateImage = function(src, width, height) { $("#changeMe"). ...

Encountered a setback while trying to add information to a MySql database through Express

When I try to execute an insert query on a database, it throws the following error: code: 'ER_PARSE_ERROR', errno: 1064, sqlMessage: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versio ...

Transforming a Datatable into an array using C#

Looking to convert a DataTable into a 2-D array in C#. Here's an example for better understanding. DataTable in C#: code Price ---------- ---------- 1146441600000 34 1146528000000 5 1146614400000 10 1146700800000 7 1146787200000 1 ...

Tips for handling a variable that could potentially be an array or a single React component

I'm diving into React for the first time and working on creating a user survey. I'm currently dealing with checkboxes in this component, which I find a bit challenging. My goal is to have the user select 2 options and then separate them with a co ...

5 Simple Steps for Adding a Value to a Popup Textbox Automatically

I want to send a value to another php page and then display the values. How can I achieve this? Here is the PHP code snippet: if(!empty($_POST["mytext"])) { for ($x=1; $x<=$a; $x++) { echo $txtLine[$x] = $_POST['mytext'.$x]; } } B ...

The most effective method for transferring asynchronous data to pages in Next.js

My current directory structure: - components - NavBar - Header - Layout - pages - pages - demo.js - _app.js - index.js // index.js import React from 'react'; import NewLayout from "../../components/NewLayout/NewLayou ...

Send user to a designated webpage and execute JavaScript code upon the loading of said page

When redirecting from one page to another, there was an issue with executing some code. if (something === true) { /* Redirect to anotherpage.php */ window.location.href = "anotherpage.php" var test = "anotherpage.php"; /* On load of anoth ...

Convert incorrectly formatted XML content into an HTML bulleted list

Currently, I am tackling a project that involves parsing an XML tree with less-than-ideal formatting. The task at hand is to create a UL structure from this XML data, but the challenge lies in all nodes having the same name with varying attributes. To achi ...

Combining multiple Stack navigators in React Native

I am currently developing a React Native application using TypeScript and functional components. My app has a deep level of nesting in its stack navigation. App: { NavigationConatainer: { DrawerNavigation: { StackNavigator1: { HomeScree ...

Generate and display a word document using JavaScript instead of prompting for a download

Is it possible to have a link that, when clicked, opens a print window for a .docx or PDF file instead of downloading or displaying the file directly? I attempted to achieve this with the following code snippet but encountered an error: var e = docume ...

Difficulty with window.locationbar.visible in Internet Explorer 11

I am currently working on detecting popups in Selenium that do not display the location bar. In my code snippet, I am using JavascriptExecutor to retrieve the visibility of the location bar in Chrome by executing the script "return window.locationbar.visi ...

Even as I create fresh references, my JavaScript array object continues to overwrite previous objects

Coming from a background in c# and c++, I am facing some confusion with a particular situation. Within the scope of my function, I am creating a new object before pushing it into an 'array'. Strangely, when I create the new object, it appears to ...

Intensive analysis of objects comparing their characteristics

Currently delving into the world of Javascript, I encountered a coding exercise involving a "deepEqual" function that I attempted to write but ultimately struggled with. Even after reviewing the solution, one particular part perplexed me - the for loop, ...