Answers for "store current date in chrome storage extension"

0

store current date in chrome storage extension

// Setting side
const currentTime = (new Date()).toJSON();
const items = { 'testdate': currentTime }; 
chrome.storage.local.set(items, () => {
    if (chrome.runtime.lastError) {
        console.error(chrome.runtime.lastError.message);
    }
});


//Getting side
chrome.storage.local.get(['testdate'], (result) => {
    if (chrome.runtime.lastError) {
        console.error(chrome.runtime.lastError.message);
    } else {
        const storedJSONDate = result['testdate'];
        const testdate = new Date(storedJSONDate);
        console.log(testdate);
    }
});
Posted by: Guest on January-05-2020

Code answers related to "store current date in chrome storage extension"

Code answers related to "Javascript"

Browse Popular Code Answers by Language