Separate date and time

后端 未结 2 1423
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 14:49

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:
\'

Posted o

相关标签:
2条回答
  • 2021-01-27 15:25

    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 element is your date string and 1th element is time string.

    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]);
    
    0 讨论(0)
  • 2021-01-27 15:35

    This was my final working code:

    var dateString = val.date; // this display my blog post date e.g. "2013-09-02 15:04:50"
    var split = dateString.split(' ');
    
    output += '<div class="postxt">Posted on <span class="posval">' + split[0] + '</span> at <span class="posval">' + split[1] + '</span></div>';
    

    Hope this helps others

    0 讨论(0)
提交回复
热议问题