Как распечатать дату в формате mm/dd/yyyy в VB

Вот небольшой пример adm-zip о том, как добавлять файлы напрямую из локального каталога и буфера:

// creating archives
var zip = new AdmZip();

// add file directly
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/"/home/me/files.zip");

В вашем случае вы можете добавлять файлы в цикл for, перебирая массив и добавляя файл в каждой рекурсии.

exports.downloadAllFiles = function(req,res){
demodb.findOne({ guid: req.params.id }, function(err, data) { 
    if (err) {
        console.log("Error in finding case....");
        res.json(HttpStatus.INTERNAL_SERVER_ERROR, {});
    } else {
        if(data){
            // for loop goes here:
            for(var i =0; i<data.length; i++){
              // add the files to zip
            }                
        }
    }
})
};
6
задан John Koerner 25 May 2012 в 19:54
поделиться

3 ответа

Протестировано в ближайшем окне и работает для меня (вывод в виде комментария)

Format(Now, "MM/dd/yyyy") '04/29/2009
Format(Date, "MM/dd/yyyy") '04/29/2009
Format(CStr(Now), "MM/dd/yyyy") '04/29/2009
Format(Date$, "MM/dd/yyyy") '04/29/2009
Format(CDate(Date), "MM/dd/yyyy")'04/29/2009

Так что, неважно, строка это или дата / время не должны иметь значения.

Правка: видел ваш комментарий для Фредрика , Неважно, как это выглядит, когда вы сохраняете его в таблицу db (формат даты столбца будет свойством db, а не ответственностью вашей программы (или vb)). Просто отформатируйте значение как и когда вы получите его из БД.

12
ответ дан 8 December 2019 в 14:47
поделиться

Note that the "/" character in date formatting functions has a special meaning, as "date separator". This means that i may be replaced with the date separator for the current locale that the program is executed in (here in Sweden it would be replaced with "-" for instance). In order to ensure that you do indeed get the "/" character in the output, I think this would work (I don't have a VB installation to verify with):

Format(date, "MM'/'dd'/'yyyy")
3
ответ дан 8 December 2019 в 14:47
поделиться

Try the next code:

Format(dt,"MM/dd/yyyy")
0
ответ дан 8 December 2019 в 14:47
поделиться
Другие вопросы по тегам:

Похожие вопросы: