반응형

어제 날짜 구하기 


#! /usr/bin/python2.7

# -*- coding: utf-8 -*-


#import datetime

#now = datetime.datetime.now()

#dt = now.strftime('%Y-%m-%d_%H:%M:%S')


import time

from datetime import date

today = date.today()

yesterday = date.fromtimestamp(time.time() - 60*60*24)

dty = yesterday.strftime('%Y-%m-%d'))

dty = yesterday.strftime('%Y%m%d')

dt = today.strftime('%Y-%m-%d')

dt = today.strftime('%Y%m%d')


print(" dty : "+ dty )

print(" dt : "+ dt )


.

반응형
반응형

ASP 날짜, 시간 - date(), Now(), time()

 

    now_a = Now()
    now_b = Left(Now(), 10)
    now_c = Mid(Date(),1,4) & Mid(Date(),6,2) & Mid(Date(),9,2) & left(FormatDateTime(Now(), 4),2)

                right(FormatDateTime(Now(), 4),2) & right(FormatDateTime(Now(), 3),2)


    response.write " now_a = "& now_a
    response.write " now_b = "& now_b
    response.write "<br> now_c = "& now_c

 

 

Now() ==> 2009-07-09 오후 4:48:49
Date() ==> 2009-07-09
Time() ==> 오후 4:48:49

FormatDateTime(Now(), 0) ==> 2009-07-09 오후 4:48:49
FormatDateTime(Now(), 1) ==> 2009년 7월 9일 목요일
FormatDateTime(Now(), 2) ==> 2009-07-09
FormatDateTime(Now(), 3) ==> 오후 4:48:49
FormatDateTime(Now(), 4) ==> 16:48

 

* YYYY-MM-DD HH24:MI:SS (오라클 기준)
FormatDateTime(Now(), 2) ==> 2009-07-09
FormatDateTime(Now(), 4) ==> 16:48
Right(Now(), 3) ==> :49
====> 2009-07-09 16:48:49

 

Left(Date(), 4) ==> 2009 (년)
Mid(Date(), 6, 2) ==> 07 (월)
Int(Mid(Date(), 6, 2)) ==> 7 (월)

반응형

+ Recent posts