日期和时间分开 [英] Separate date and time

查看:81
本文介绍了日期和时间分开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码行,并且还想显示时间,但是要在日期和时间之间添加一个文本:

I have the following line of code and would like to display the time also but add a text between the date and time:

Code:
'<p class="postedon" >Posted on ' + val.date.substring(0,10)

如图所示,我使用了一个子字符串来仅显示日期,但是使用该子字符串,这就是我的移动应用程序上显示的内容

As seen, i used a substring to only display the date but with the substring this is what is displayed on my mobile app

2013-09-01 16:20

2013-09-01 16:20

我要实现的是:日期+时间+时间

What I want to achieve is: date + at + time

2013-09-01在16:20

2013-09-01 at 16:20

推荐答案

在Java中,更好的方法是

In java , better way is

String dateString = "2013-09-01 16:20";
String[] split = dateString .split(s);
System.out.println(split[0]+" at "+split[1]);

0th元素是您的日期字符串,而1th元素是时间字符串.

0th element is your date string and 1th element is time string.

如果您对Java和javascript感到困惑,那么

If you are confused with java and javascript then

var dateString = "2013-09-01 16:20";
var split = dateString .split(s);
consol.log(split[0]+" at "+split[1]);

这篇关于日期和时间分开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆