Utilizing firebase functions, I am trying to retrieve a date that is 30 days from the current date in MM-DD-YYYY format. However, when attempting to import datepipe, I encountered an error stating: Detailed stack trace: Error: Cannot find module '@angular/common'.
index.ts:
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
admin.initializeApp();
exports.scheduledFunction =
functions.pubsub.schedule("every 5 minutes").onRun((context) => {
const currentDate = new Date();
const targetDate = new Date().setDate(currentDate.getDate() + 30);
console.log("Target Date" + targetDate);
admin.database().ref("reservations/").update({zafer: "zafer5353"});
return null;
});
Console.log(targetDate) output is :1648669741663 How can I convert it to MM-DD-YYYY
package.json in functions:
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "16"
},
"main": "lib/index.js",
"dependencies": {
"@angular/common": "^13.2.4",
"@angular/fire": "^7.2.1",
"firebase": "^9.6.7",
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.22.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^3.8.0"
},
"private": true
}